Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useMutableSource hydration support #18771

Merged
merged 4 commits into from
May 21, 2020

Conversation

bvaughn
Copy link
Contributor

@bvaughn bvaughn commented Apr 28, 2020

Add hydration support for useMutableSource (resolves #18183)

View diff without white space.

Usage example

// 1. Render app on the server...

// 2. Create root for hydration. and pre-register all mutable sources.
// This eagerly records source versions to guard against tearing during (async) hydration.
const root = ReactDOM.unstable_createRoot(container, {
  hydrate: true,
  mutableSources: [relayMutableSource],
});

// 3. Render and hydrate like normal.
root.render(<Application />);

MVP checklist

  • Determine if the change in behavior to unsafe useOpaqueIdentifier reads inside of a Suspense boundary is valid (cc @lunaruan).
  • Get consensus on the new API.

Follow up work

  • useMutableSource: Release version snapshots once hydration is finished #18835: Decide when to clear mutableSourceEagerHydrationData. We don't currently have a way to detect when all outstanding hydration work is finished. (It may never finish.) This means that in use cases where the version is the entire sore (e.g. an immutable store without a version "number") we would retain a reference to that store, preventing it from being GCed.

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Apr 28, 2020
@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 28, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit ec01142:

Sandbox Source
distracted-antonelli-dp5nz Configuration

@sizebot
Copy link

sizebot commented Apr 28, 2020

Warnings
⚠️ Failed to fetch build artifacts for base commit: 23309eb

Size changes (stable)

Generated by 🚫 dangerJS against ec01142

@sizebot
Copy link

sizebot commented Apr 28, 2020

Warnings
⚠️ Base commit is broken: 23309eb

Size changes (experimental)

Generated by 🚫 dangerJS against ec01142

@bvaughn bvaughn force-pushed the useMutableSource-hydration branch 7 times, most recently from 5fb3163 to a7832bd Compare May 5, 2020 21:27
@bvaughn bvaughn marked this pull request as ready for review May 5, 2020 22:26
@bvaughn bvaughn force-pushed the useMutableSource-hydration branch from a7832bd to ca0e967 Compare May 5, 2020 22:27
@bvaughn bvaughn changed the title useMutableSource hydration support (DRAFT) useMutableSource hydration support May 5, 2020
@bvaughn bvaughn force-pushed the useMutableSource-hydration branch from ca0e967 to 2e47d3a Compare May 6, 2020 18:14
@bvaughn bvaughn force-pushed the useMutableSource-hydration branch 2 times, most recently from a110dc2 to 29f8b13 Compare May 8, 2020 18:38
Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation looks good but let's change the API to pass through the options object (if you agree).

@bvaughn
Copy link
Contributor Author

bvaughn commented May 8, 2020

No objection. I had made and stashed that change earlier because I didn't feel strongly about it. Just pushed it.

@bvaughn bvaughn requested a review from sebmarkbage May 8, 2020 20:01
@bvaughn
Copy link
Contributor Author

bvaughn commented May 11, 2020

(Back to you with the options change, @sebmarkbage )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useMutableSource and hydration
5 participants