-
Notifications
You must be signed in to change notification settings - Fork 48.5k
[Fiber] Support AsyncIterable children in SuspenseList #33299
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
[Fiber] Support AsyncIterable children in SuspenseList #33299
Conversation
) { | ||
// TODO: Technically we should warn for nested arrays inside the | ||
// async iterable but it would require unwrapping the array. | ||
// However, this mistake is not as easy to make so it's ok not to warn. |
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.
It can be costly to iterate this twice so we avoid it.
Ideally, we'd probably move the validateSuspenseListChildren
warning to be integrated with the rest ChildFiber instead so that it can be done in a single pass. Even for sync iterators.
Comparing: 462d08f...504a75a Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
validateTailOptions(tailMode, revealOrder); | ||
validateSuspenseListChildren(newChildren, revealOrder); | ||
|
||
reconcileChildren(current, workInProgress, newChildren, renderLanes); |
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.
reconcileChildren
can suspend which lead to the SuspenseListContext
to be unbalanced so it needs to push first.
function Foo() { | ||
return ( | ||
<SuspenseList revealOrder="forwards"> | ||
<Generator /> |
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.
This pattern would be very convenient but we can't support it since we need to resolve the rows first.
Interestingly this pattern is supported in Server Components because they get resolved into the iterable on the server and the component wrapper disappears. It's just not supported in Client Components.
36c245f
to
504a75a
Compare
We support AsyncIterable (more so when it's a cached form like in coming from Flight) as children. This fixes some warnings and bugs when passed to SuspenseList. Ideally SuspenseList with `tail="hidden"` should support unblocking before the full result has resolved but that's an optimization on top. We also might want to change semantics for this for `revealOrder="backwards"` so it becomes possible to stream items in reverse order. DiffTrain build for [4c6967b](4c6967b)
We support AsyncIterable (more so when it's a cached form like in coming from Flight) as children. This fixes some warnings and bugs when passed to SuspenseList. Ideally SuspenseList with `tail="hidden"` should support unblocking before the full result has resolved but that's an optimization on top. We also might want to change semantics for this for `revealOrder="backwards"` so it becomes possible to stream items in reverse order. DiffTrain build for [4c6967b](4c6967b)
We support AsyncIterable (more so when it's a cached form like in coming from Flight) as children.
This fixes some warnings and bugs when passed to SuspenseList.
Ideally SuspenseList with
tail="hidden"
should support unblocking before the full result has resolved but that's an optimization on top. We also might want to change semantics for this forrevealOrder="backwards"
so it becomes possible to stream items in reverse order.