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

Use useId instead of React internals #3254

Merged
merged 4 commits into from
May 29, 2024

Conversation

eps1lon
Copy link
Contributor

@eps1lon eps1lon commented May 29, 2024

These may break in any React release which may result in blocking the ecosystem from seemlessly upgrading to new React releases.

We can use useId instead which is available since React 18.

Keep in mind that the whole hook is not safe in concurrent rendering. It increments render during render but only decrements in an effect cleanup. React may render multiple times before actually committing. The keys would leak in those scenarios (e.g. when a sibling suspends).

Closes #3167

These may break in any React release which may result in blocking the ecosystem from seemlessly upgrading to new React releases.

We can use `useId` instead which is available since React 18.
Copy link

vercel bot commented May 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
headlessui-react ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 1:45pm
headlessui-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 1:45pm

No need to use `useStableCollectionKey` anymore
@RobinMalfait
Copy link
Member

Hey!

Thanks for the PR, I did inline the useId hook directly but apart from that everything looks good to me. Thanks!

@RobinMalfait RobinMalfait merged commit 3070ad9 into tailwindlabs:main May 29, 2024
8 checks passed
@eps1lon eps1lon deleted the react-19-compat branch May 29, 2024 14:09
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 this pull request may close these issues.

Incompatible with React 19 due to use of __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
2 participants