-
Notifications
You must be signed in to change notification settings - Fork 47.1k
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
[Flight] Chunks API #17398
[Flight] Chunks API #17398
Conversation
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 3062dfc:
|
Details of bundled changes.Comparing: 4c27037...3062dfc react
react-native-renderer
react-reconciler
react-dom
react-art
react-test-renderer
ReactDOM: size: 🔺+0.2%, gzip: 🔺+0.1% React: size: 🔺+0.2%, gzip: 🔺+0.1% Size changes (stable) |
Details of bundled changes.Comparing: 4c27037...3062dfc react
react-dom
react-test-renderer
react-native-renderer
react-art
react-reconciler
ReactDOM: size: 🔺+0.3%, gzip: 🔺+0.2% React: size: 🔺+1.3%, gzip: 🔺+0.9% Size changes (experimental) |
$$typeof: REACT_CHUNK_TYPE, | ||
query: function() { | ||
return query.apply(null, args); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Flight, this function will be replaced by one that suspends on the data, as well as as a render that suspends on the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks OK overall but the child fiber stuff is fragile and there's a bug. I think we need to ensure we have coverage for every branch we're changing before landing this.
QQ: From what I can see, this looks like it would work in legacy mode too, right? If so, is that intentional? |
62c9f11
to
74318e2
Compare
This allows the query and args to be updated.
Not really a supported use case but for consistency I guess.
* Add feature flags * Add Chunk type and constructor * Wire up Chunk support in the reconciler * Update reconciler to reconcile Chunks against the render method This allows the query and args to be updated. * Drop the ref. Chunks cannot have refs anyway. * Add Chunk checks in more missing cases * Rename secondArg * Add test and fix lazy chunks Not really a supported use case but for consistency I guess. * Fix fragment test
This is a very early experiment. We just need something to play with.
This is a new core API but it's not really meant to be used without Flight. Instead Flight will produce these "chunks" from its payload. The primary purpose of this in core is to ensure the reconciler can update the same component instance with new data.
It can be used without Flight by running it in the same environment and it works fine. That is a nice property because a) it means you can get started running this code in a client-only environment and debug in browser. b) it describes the semantics in a standalone way which is how the type system thinks about it, so it's nice to be able to think about it this way.
This implementation doesn't support Context. Exposing React's context wouldn't be the same semantics as with Flight so it's not super easy and requires more code to actually support Context in this mode. That's unfortunate.