-
Notifications
You must be signed in to change notification settings - Fork 47k
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: putting promise into JSX will cause hydration issue #27778
Comments
Related downstream repo: dai-shi/waku#203 |
I think this is a React issue, not next.js. Since our customized react framework has the same error |
Sorry, Promise is serealizable. I misunderstood. |
Values of serialized promises are different between client side and server side. |
The issue can be resolved by using useEffect hook . |
I found a workaround for this matter. It is to use However, looking at the following PR, it appears that this workaround is not supposed to be necessary. And it seems to be related to the following Issue discussed in the Next.js repository. |
Since promise is a valid jsx element, I think it should not cause ssr issues or otherwise should be documented |
@himself65 , Thanks for reporting the hydration issue with promises in JSX. Putting promises directly in JSX can be tricky in React 18. Render a placeholder on the server while the promise resolves on the client (e.g., a loading spinner). Update the DOM with the resolved value once it's available. For more advanced handling, consider Suspense or data fetching libraries like react-query or SWR. Happy coding! |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
bump |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you! |
React version: 18.3.0-canary-5dd35968b-20231201
Steps To Reproduce
Link to code example:
The current behavior
The expected behavior
Won't have hydration error
The text was updated successfully, but these errors were encountered: