Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 57e4d6872fe5786220d23aa4781ff33af65ffeaa
Choose a base ref
...
head repository: facebook/react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ffdf8a114576329a9db12ae3e2f66f9032c56e0b
Choose a head ref
  • 1 commit
  • 12 files changed
  • 1 contributor

Commits on Sep 20, 2021

  1. Implement useSyncExternalStore on server

    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.
    acdlite committed Sep 20, 2021
    Configuration menu
    Copy the full SHA
    ffdf8a1 View commit details
    Browse the repository at this point in the history
Loading