react/scripts
Luna Ruan 3278d24218
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>
2020-04-06 17:17:27 -07:00
..
babel Check in a forked version of object-assign only for UMD builds (#18180) 2020-02-28 11:14:09 -08:00
bench Bump minimist from 1.2.0 to 1.2.3 in /scripts/bench (#18500) 2020-04-06 19:29:11 +01:00
circleci Remove /dist/ UMD builds (#18473) 2020-04-02 17:52:32 -07:00
error-codes Add useOpaqueIdentifier Hook (#17322) 2020-04-06 17:17:27 -07:00
eslint [Flight] Lazily parse models and allow any value to suspend (#18476) 2020-04-03 14:58:02 -07:00
eslint-rules Additional test infra changes for toErrorDev rename (#17632) 2019-12-17 13:31:47 +00:00
flow Enable prefer-const lint rules (#18451) 2020-04-01 12:35:52 -07:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest Update to Jest 25 (#18480) 2020-04-03 16:37:36 +01:00
perf-counters Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
prettier Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
print-warnings Update Flow to 0.84 (#17805) 2020-01-09 14:50:44 +00:00
release Remove error code step from publish script (#18350) 2020-03-19 14:45:07 -07:00
rollup [Flight] Add webpack plugin build (#18485) 2020-04-03 14:04:56 -07:00
shared [Flight] Lazily parse models and allow any value to suspend (#18476) 2020-04-03 14:58:02 -07:00
tasks Change ReactVersion from CJS to ES module (#18181) 2020-02-28 13:09:02 -08:00
yarn chore: upgrade to jest 24 (#15778) 2019-10-03 22:44:18 +05:30
authors AUTHORS 2013-09-09 23:42:54 -07:00