Skip to content

[All] Remove IdProvider and introduce React.useId #1006

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

Merged
merged 2 commits into from
Nov 30, 2021
Merged

[All] Remove IdProvider and introduce React.useId #1006

merged 2 commits into from
Nov 30, 2021

Conversation

jjenzz
Copy link
Contributor

@jjenzz jjenzz commented Nov 30, 2021

For older versions of React we are falling back to client-only ids. This removes the overhead of an IdProvider given that projects will likely migrate to React 18 eventually.

Fixes #811

Notes for docs

@jjenzz jjenzz force-pushed the use-id-r18 branch 3 times, most recently from be71cda to 141d1da Compare November 30, 2021 15:58
@jjenzz jjenzz marked this pull request as draft November 30, 2021 15:59
@jjenzz jjenzz force-pushed the use-id-r18 branch 4 times, most recently from 9a39891 to 12ab053 Compare November 30, 2021 16:12
@jjenzz jjenzz marked this pull request as ready for review November 30, 2021 16:16
);
const handleClose = useCallbackRef(() => {
stateMachine.send({ type: 'CLOSE', id: contentId, skipDelayDuration });
});

// send transition if the component unmounts
React.useEffect(() => () => handleClose(), [handleClose]);
Copy link
Contributor Author

@jjenzz jjenzz Nov 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The handleClose had a contentId dependency which would start as undefined so this hook would call its cleanup when the contentId was set on client and instantly close the defaultOpen tooltips.

Using useCallbackRef for handleClose instead solves it for now but I need to create a new TooltipProvider as part of this React 18 piece to ensure our state is all managed through React state / Context, so I'll see if I can make any improvements here then as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took me a while 😅

@jjenzz jjenzz merged commit 14cc2ee into main Nov 30, 2021
@jjenzz jjenzz deleted the use-id-r18 branch November 30, 2021 20:04
@byF
Copy link

byF commented Dec 6, 2021

@benoitgrelard
Copy link
Contributor

@jjenzz I guess this PR invalidates the docs at https://www.radix-ui.com/docs/primitives/overview/server-side-rendering?

It will yes, it's not released publicly as stable yet, although it is part of the release candidates.

@jjenzz
Copy link
Contributor Author

jjenzz commented Dec 7, 2021

@byF Thanks for the reminder, I've updated the original PR description to include notes on required docs updates.

@andrevenancio
Copy link

I've noticed that now there's no need to have this module wrapping my app, but leaving that documentation page online is confusing..

@benoitgrelard
Copy link
Contributor

We are in the process of releasing and the docs are almost out.
Sorry about the inconvenience.

Copy link

@polRk polRk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you let this happen?

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.

[Id] SSR – Mismatched server / client ids when running in StrictMode
5 participants