Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSR hydration warning #17

Open
thorsten-stripe opened this issue Jun 13, 2020 · 0 comments
Open

SSR hydration warning #17

thorsten-stripe opened this issue Jun 13, 2020 · 0 comments

Comments

@thorsten-stripe
Copy link

Hey, this module is great and we use it over at https://github.com/dayhaysoos/use-shopping-cart :) ❤️

We've had some folks run into this issue (dayhaysoos/use-shopping-cart#122) which seems to be a hydration warning because the server-side rendered value differs from the value on the client.

Have you seen that before by any chance? I did some digging, and the general recommendation is to use the same initial state as on the server, and then update it in a useEffect hook, but I'm not sure if that's possible within a custom hook 🤔

Reproduction steps

I've set up an environment to reproduce: https://codesandbox.io/s/autumn-grass-vhu4e?expanddevtools=1&fontsize=14&hidenavigation=1&theme=dark

  1. Navigate to CodeSandbox
  2. Switch to the Console tab (Second tab next to Terminal in the bottom right dev tools)
  3. Click the + button a couple times so counter is !== 0
  4. Click preview reload button
  5. See warning in console

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant