-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
useSyncExternalStore
causes Error on Hydration of SSR React Page
#3669
Comments
I have a PR ready (#3670), but to be clear, does it throw on the server or during hydration on the client? React documentation is perhaps a bit misleading?
Actually throws on the client? ...
But then it throws ? ... |
From what I checked, yes it throws. I appreciate your effort, I might have the chance to check your PR out if it would fix my problem tomorrow. |
I had the same issue and tested out the PR at #3670 and looks like it fixed it for me. my setup is fairly weird...a web worker generates some html and we use it to hydrate stuff on the main thread I added a console.log right before the throw to determine if it's on the server side (which in my case is a web worker) or main thread, and it is main thread |
might be able to see reproduction here https://codesandbox.io/s/great-carlos-l6ewrk?file=/App.js (see problems tab) |
Just finished testing and based on 58bb052 it seems to work properly now. |
Intended outcome:
MobX shouldn't throw an error and function as expected when part of a SSR stack. It should provide a
getServerSnapshot
parameter to theuseSyncExternalStore
call, which is required for hydrating pages.Actual outcome:
Currently after the latest update (which to my knowledge moved MobX' React Integration to support
useSyncExternalStore
hydration of pages using MobX will causeHow to reproduce the issue:
I have a fairly complex setup and sadly not enough time to provide a reproduction of the effect.
It occurs for me when I utilize the
observer(Component)
wrapper function, from what I can see.Versions
4.0.2
The text was updated successfully, but these errors were encountered: