-
Notifications
You must be signed in to change notification settings - Fork 46.9k
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: Suspense | client component should have a queue #25964
Comments
Hello, can you explain what is happening ? |
@xiel Could you also open this against vercel/next.js. They probably know best how to create a minimal repro that just uses React code. |
opened issue in next repo: vercel/next.js#44686 feel free to close this issue, if you think it is only relevant to next.js |
Hi there, any update on when this issue is going to get fixed? We are trying to integrate use() in some of our client components, but got blocked due to this. And a higher level question, how far we are from |
This happens because we end up calling the update version of useState rather than the mount version since React knows this is not a new Fiber. It seems like we do want to retain the past state of the Hooks we have already called, but we also need to accommodate the case that we are calling a Hook for the first time. @acdlite WDYT? Right now updateMemo is resilient to receiving an empty workInProgressHook (and you have a test for that one!) but updateReducer is not. I saw this comment: react/packages/react-reconciler/src/ReactFiberHooks.js Lines 844 to 845 in ca2cf31
Is updating the dispatcher mid-render still your thinking? Is there a good place to do that? (Once the next hook is called, we are already in an update-only path…) Or I guess we could make updateWorkInProgress return null in this case and have all the update hooks handle that possibility? |
Yeah the plan is to detect when it runs out of hooks from the previous attempt and switch to the mount dispatcher. This bug only happens with I'll submit a fix soon, have a few other things I need to do first. If someone else wants to give it a go in the meantime I'll happily review the PR, though it is a bit of a tricky one. |
When resuming a suspended render, there may be more Hooks to be called that weren't seen the previous time through. Make sure to switch to the mount dispatcher when calling use() if the next Hook call should be treated as a mount. Fixes facebook#25964.
When resuming a suspended render, there may be more Hooks to be called that weren't seen the previous time through. Make sure to switch to the mount dispatcher when calling use() if the next Hook call should be treated as a mount. Fixes facebook#25964.
When resuming a suspended render, there may be more Hooks to be called that weren't seen the previous time through. Make sure to switch to the mount dispatcher when calling use() if the next Hook call should be treated as a mount. Fixes facebook#25964.
When resuming a suspended render, there may be more Hooks to be called that weren't seen the previous time through. Make sure to switch to the mount dispatcher when calling use() if the next Hook call should be treated as a mount. Fixes #25964.
React version: 18.2.0
Next version: 13.1.1
Steps To Reproduce
Link to code example:
https://codesandbox.io/s/github/xiel/app-playground/tree/suspense-error/?from-embed=&file=/app/page.tsx
The current behavior
Suspending for a promise in a client component and using state/reducer after results in errors during hydration:
The expected behavior
No error during hydration.
The text was updated successfully, but these errors were encountered: