-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
React 18: Updating state in an effect during mount causes hydration mismatch #1794
Comments
I'm kind of confused by the "hydration" wording here. Is this SSR-related, or purely client-side? |
This seems like a React bug, not a React Redux bug. The fact that If the data on context is out of sync at that point, it would be up to React to be providing the prior value, or to not complain about hydration mismatches in suspended subtrees. |
SSR-related as shown in the codesandbox.
Given that I see no hydration warnings using React Context, I don't believe this is a React bug. But if you can reproduce the same issue with just React, we can file it against the React repository. |
I'd kinda like to see if this is reproducible with anything non-Redux-related. |
Is this something I should do? Because I already tried with just React Context without success. At this point I'd have to dig into how react-redux works. |
If you could, yes, please. I certainly don't have time or priority to look into this myself. My question is whether this is likely unrelated to Redux or React-Redux, and rather something about a non-React-based external store. Like, try doing this with Zustand, Mobx, Jotai, and Redux-Zero, or even a minimal Redux store and hand-written subscription, and see if any of them exhibit similar behavior. |
The only thing I could think of is our use of |
Reduced the issue to Will revisit once facebook/react#22239 lands. The shim triggers a warning that it doesn't support React 18:
|
Closing since this issue caused by author error not library error: facebook/react#22361 (comment) |
What version of React, ReactDOM/React Native, Redux, and React Redux are you using?
What is the current behavior?
When updating the store in an effect outside of a Suspense boundary, hydration mismatches are reported for components reading from the store inside Suspense boundaries.
Warning: Prop `className` did not match. Server: "language-js" Client: "language-ts"
Components reading the store outside of Suspense boundaries issue no hydration mismatches.
Example: https://codesandbox.io/s/react-18-updating-state-in-an-effect-during-mount-causes-hydration-mismatch-w7tjt?file=/src/App.js:2208-2372
The codesandbox includes an implementation using React Context as well where no problem is reported.
What is the expected behavior?
No hydration mismatches.
Which browser and OS are affected by this issue?
Chrome 92, Ubuntu 20.04
Did this work in previous versions of React Redux?
The text was updated successfully, but these errors were encountered: