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

feat/fix(ssr): Fix hydration errors, remove need for resetServerContext when useId is available (i.e. React 18+) #430

Closed
wants to merge 1 commit into from

Conversation

klarstrup
Copy link
Contributor

@klarstrup klarstrup commented Oct 31, 2022

This fixes hydration errors of the sort:

Warning: Prop `aria-describedby` did not match. Server: "rfd-hidden-text-1-hidden-text-8" Client: "rfd-hidden-text-1-hidden-text-1"

Even with proper usage of resetServerContext(), this error can crop up when doing sufficiently concurrent SSR.

It also adds a warning for when resetServerContext is called unnecessarily.


Following the addition of React 18 support the resettable hacky increment-only IDs can be dropped in favor of the first party useId() API (details: https://reactjs.org/docs/hooks-reference.html#useid)

This should not be a breaking change per se but the new IDs could result in broken snapshot tests among consumers, as indeed it did here.

@vercel
Copy link

vercel bot commented Oct 31, 2022

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

Name Status Preview Updated
dnd ✅ Ready (Inspect) Visit Preview Oct 31, 2022 at 2:39PM (UTC)

@klarstrup klarstrup changed the title feat(ssr): remove need for resetServerContext when useId is available (i.e. React 18+) feat/fix(ssr): remove need for resetServerContext when useId is available (i.e. React 18+) Oct 31, 2022
@klarstrup klarstrup changed the title feat/fix(ssr): remove need for resetServerContext when useId is available (i.e. React 18+) feat/fix(ssr): Fix hydration errors, remove need for resetServerContext when useId is available (i.e. React 18+) Oct 31, 2022
@Xhale1
Copy link
Collaborator

Xhale1 commented Nov 19, 2022

This looks good to me. @100terres do you wanna take a second look?

@100terres
Copy link
Collaborator

Thank you @klarstrup for your contribution! I wanted to do some changes, but I wasn't able to do it directly on your branch. I've open a new pull request with your changes 🙂

Follow this pull request ➡️ #439

@100terres 100terres closed this Nov 26, 2022
@100terres
Copy link
Collaborator

#439 has been merged! Thank you again 🙂

@100terres 100terres removed their request for review February 20, 2023 16:24
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.

3 participants