-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Bug: Error due to serverSnapshot
and snapshot
mismatch in useSyncExternalStore
when used with Suspense
SSR
#26318
Comments
serverSnapshot
and snapshot
mismatch in useSyncExternalStore
and Suspense
serverSnapshot
and snapshot
mismatch in useSyncExternalStore
when used with Suspense
serverSnapshot
and snapshot
mismatch in useSyncExternalStore
when used with Suspense
serverSnapshot
and snapshot
mismatch in useSyncExternalStore
when used with Suspense
SSR
I'm not seeing any error when opening https://codesandbox.io/s/usesyncexternalstore-suspense-bug-lyoc03?file=/src/App.js:217-241. Did you maybe change the codesandbox in the meantime? |
@eps1lon Hi, I haven't updated the code in Codesandbox. I'm not entirely sure why the error message isn't showing up in the Codesandbox environment's console maybe it has something to do with how this error is logged, but you can still see the error by checking out the browser console. By looking at the Codesandbox environment's browser console or by opening the direct browser view link: https://lyoc03.sse.codesandbox.io/. Here's a screenshot if that helps: |
Ah gotcha, error didn't display in codesandbox console. This was fixed in #25692. The next stable release should have this. In the meantime, you can verify it by using |
@eps1lon Tested it in the React version: 18.3.0-next-a8875eab7-20230310 Steps To Reproduce
Link to code example: https://codesandbox.io/p/sandbox/usesyncexternalstore-suspense-bug-forked-drm325 The current behaviorThe suspended component on the client side fully rerenders. Falls into a fallback state and then renders its content. Due to a mismatch between The expected behaviourThe suspended component doesn't do a full rerender(falls into a fallback state and then renders its content):
I assume the expected behaviour should be: the suspended component shouldn't do a full rerender(fall into a fallback state and then render its content) when Additional contextOne use case when |
React version: 18.2.0
Steps To Reproduce
Suspense
SSR anduseSyncExternalStore
in the same component.serverSnapshot
andsnapshot
inuseSyncExternalStore
are different.Link to code example: https://codesandbox.io/s/usesyncexternalstore-suspense-bug-lyoc03?file=/src/App.js:49-69
The current behavior
Error message appears:
Due to a mismatch between
serverSnapshot
andsnapshot
when usingSuspense
anduseSyncExternalStore
in the same component.The expected behaviour
The error doesn't appear:
serverSnapshot
andsnapshot
are identical.useSyncExternalStore
has a mismatch betweenserverSnapshot
andsnapshot
and is used in a component without aSuspense
boundary.I assume the expected behaviour should be: no error when
useSyncExternalStore
is used withSuspense
in the same component.Question
Maybe there is a possible temporary patch for this issue?
The text was updated successfully, but these errors were encountered: