-
Notifications
You must be signed in to change notification settings - Fork 47.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add useOpaqueIdentifier Hook (#17322)
* Add useOpaqueIdentifier Hook We currently use unique IDs in a lot of places. Examples are: * `<label for="ID">` * `aria-labelledby` This can cause some issues: 1. If we server side render and then hydrate, this could cause an hydration ID mismatch 2. If we server side render one part of the page and client side render another part of the page, the ID for one part could be different than the ID for another part even though they are supposed to be the same 3. If we conditionally render something with an ID , this might also cause an ID mismatch because the ID will be different on other parts of the page This PR creates a new hook `useUniqueId` that generates a different unique ID based on whether the hook was called on the server or client. If the hook is called during hydration, it generates an opaque object that will rerender the hook so that the IDs match. Co-authored-by: Andrew Clark <git@andrewclark.io>
- Loading branch information
Showing
24 changed files
with
1,370 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.