Skip to content
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

useMeasure: React18 Support (Suspense boundary breaks when using the hook) #2505

Open
karanpvyas opened this issue Jun 20, 2023 · 3 comments · May be fixed by #2506
Open

useMeasure: React18 Support (Suspense boundary breaks when using the hook) #2505

karanpvyas opened this issue Jun 20, 2023 · 3 comments · May be fixed by #2506

Comments

@karanpvyas
Copy link

karanpvyas commented Jun 20, 2023

What is the current behavior?
On using useMeasure it is giving the below error with React18 (with server side rendering)
Error: This Suspense boundary received an update before it finished hydrating. This caused the boundary to switch to client rendering. The usual way to fix this is to wrap the original update in startTransition.

This is happening because of using setState for "refs"

Steps to reproduce it and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have extra dependencies other than react-use. Paste the link to your JSFiddle or CodeSandbox example below:
https://codesandbox.io/s/poc-hydration-error-skz31g?file=/pages/index.js
image

What is the expected behavior?
There should be no Suspense Hydration Error

A little about versions:

  • OS:
  • Browser (vendor and version):
  • React: 18.0.2
  • react-use: 17.4.0
  • Did this worked in the previous package version? No
@arnaugomez
Copy link

I would like to contribute to this issue, give me some time and I'll look for a fix

@arnaugomez
Copy link

@karanpvyas I solved the issue! I am going to make a PR soon. This is my first contribution to GitHub so I am very new to this. But I will try my best.

@arnaugomez arnaugomez linked a pull request Jun 30, 2023 that will close this issue
13 tasks
@arnaugomez
Copy link

arnaugomez commented Jun 30, 2023

@karanpvyas I created a PR that solves your problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants