react/scripts
Andrew Clark 86b3e2461d
Implement useSyncExternalStore on server (#22347)
Adds a third argument called `getServerSnapshot`.

On the server, React calls this one instead of the normal `getSnapshot`.
We also call it during hydration.

So it represents the snapshot that is used to generate the initial,
server-rendered HTML. The purpose is to avoid server-client mismatches.
What we render during hydration needs to match up exactly with what we
render on the server.

The pattern is for the server to send down a serialized copy of the
store that was used to generate the initial HTML. On the client, React
will call either `getSnapshot` or `getServerSnapshot` on the client as
appropriate, depending on whether it's currently hydrating.

The argument is optional for fully client rendered use cases. If the
user does attempt to omit `getServerSnapshot`, and the hook is called
on the server, React will abort that subtree on the server and
revert to client rendering, up to the nearest Suspense boundary.

For the userspace shim, we will need to use a heuristic (canUseDOM)
to determine whether we are in a server environment. I'll do that in
a follow up.
2021-09-20 08:31:02 -07:00
..
babel Add comment support to `@gate` pragma (#21881) 2021-07-14 10:36:24 -07:00
bench Bump ecstatic from 2.2.1 to 2.2.2 in /scripts/bench (#20468) 2021-06-29 16:53:31 -04:00
circleci lint-build: Infer format from artifact filename (#21489) 2021-05-12 10:14:45 -07:00
devtools [DevTools] Fix Issue in release script where commits for the last DevTools release are undefined #22233 2021-09-01 12:56:39 -07:00
error-codes Implement useSyncExternalStore on server (#22347) 2021-09-20 08:31:02 -07:00
eslint Pass extra CLI args through to ESLint (#20250) 2020-11-13 11:00:45 -08:00
eslint-rules feat(eslint-plugin-react-internal): support ESLint 8.x (#22249) 2021-09-06 20:42:40 +01:00
flow Console Logging for StrictMode Double Rendering (#22030) 2021-08-25 15:35:38 -07:00
git Remove leftover env variable logic in pre-commit hook 2015-09-01 14:35:47 -07:00
jest Check for store mutations before commit (#22290) 2021-09-13 08:07:46 -07:00
merge-fork replace-fork: Cleanup after failure if no unstaged changes (#22364) 2021-09-20 11:10:17 -04:00
perf-counters Drop the year from Facebook copyright headers and the LICENSE file. (#13593) 2018-09-07 15:11:23 -07:00
prettier DevTools: Update named hooks match to use column number also (#21833) 2021-07-08 16:12:22 -04:00
print-warnings Fix link to fbjs (#21863) 2021-07-13 10:55:33 -04:00
release Bump ws from 6.1.2 to 6.2.2 in /scripts/release (#21628) 2021-06-29 16:53:39 -04:00
rollup Fixed broken build script --unsafe-partial flag (#22324) 2021-09-15 13:32:09 -04:00
shared Updated scripts and config to replace "master" with "main" branch (#21768) 2021-06-29 14:26:24 -04:00
tasks Parallelize Flow in CI (#20794) 2021-02-10 17:54:58 -06: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