Skip to content

CartProvider causes SSR warning in the terminal #2663

Closed
@jeremyagabriel

Description

What is the location of your example repository?

No response

Which package or tool is having this issue?

hydrogen-react

What version of that package or tool are you using?

2024.10.0

What version of Remix are you using?

2.15.0

Steps to Reproduce

  1. Wrap the root's layout with ShopifyProvider and CartProvider from @shopify/hydrogen-react
  2. Run npm run dev and observe warning in terminal

Expected Behavior

Expected behavior is that there is no SSR warning in the terminal.

Actual Behavior

Actual behavior is this warning in the terminal every time the server loads or reloads:

Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
at CartProvider (/Users/...)
at ShopifyProvider (/Users/..)
...

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions