Skip to content

Commit c38e268

Browse files
[Fiber] Fix hydration of useId in SuspenseList (#33491)
Includes #31412. The issue is that `pushTreeFork` stores some global state when reconcile children. This gets popped by `popTreeContext` in `completeWork`. Normally `completeWork` returns its own `Fiber` again if it wants to do a second pass which will call `pushTreeFork` again in the next pass. However, `SuspenseList` doesn't return itself, it returns the next child to work on. The fix is to keep track of the count and push it again it when we return the next child to attempt. There are still some outstanding issues with hydration. Like the backwards test still has the wrong behavior in it because it hydrates backwards and so it picks up the DOM nodes in reverse order. `tail="hidden"` also doesn't work correctly. There's also another issue with `useId` and `AsyncIterable` in SuspenseList when there's an unknown number of children. We don't support those showing one at a time yet though so it's not an issue yet. To fix it we need to add variable total count to the `useId` algorithm. E.g. by falling back to varint encoding. --------- Co-authored-by: Rick Hanlon <rickhanlonii@fb.com> Co-authored-by: Ricky <rickhanlonii@gmail.com>
1 parent 80c03eb commit c38e268

File tree

4 files changed

+390
-2
lines changed

4 files changed

+390
-2
lines changed

0 commit comments

Comments
 (0)