mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
* 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>
|
||
|---|---|---|
| .. | ||
| babel | ||
| bench | ||
| circleci | ||
| error-codes | ||
| eslint | ||
| eslint-rules | ||
| flow | ||
| git | ||
| jest | ||
| perf-counters | ||
| prettier | ||
| print-warnings | ||
| release | ||
| rollup | ||
| shared | ||
| tasks | ||
| yarn | ||
| authors | ||