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

Disclosure component bug: This Suspense boundary received an update before it finished hydrating #2233

Closed
migueloller opened this issue Jan 31, 2023 · 3 comments · Fixed by #2238
Assignees

Comments

@migueloller
Copy link

What package within Headless UI are you using?

@headlessui/react

What version of that package are you using?

v1.7.8

What browser are you using?

Chrome

Reproduction URL

https://github.com/migueloller/headless-ui-disclosure-suspense-repro

Describe your issue

Using a Disclosure component with defaultOpen set to true with a Suspense boundary on the panel will result in the following error:

CleanShot 2023-01-31 at 16 38 20

@migueloller
Copy link
Author

Note that this error only happens on a hard-reload (it's happening during hydration) when defaultOpen is set to true or if defaultOpen is set to false, you can set static to true in Disclosure.Panel. There seems to be a state change in the Disclosure component that happens before React has finished hydrating. Possibly because the component does the state change during render instead of in an effect?

As the error message mentions, perhaps this state changed should be wrapped in startTransition?

Related:

@RobinMalfait
Copy link
Member

Hey! Thank you for your bug report!
Much appreciated! 🙏

This is indeed an odd/annoying bug. That said this should be fixed by #2238, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders.

@raphaelreimann
Copy link

Hey @RobinMalfait, I was running into a similar problem with the Tabs component but upgrading to the insiders version solved it. Thanks so much 🙂

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