Commit df27420
committed
Skip finalizeContainerChildren for suspended transition
Work-in-progress idea targeting the same situation as #30513.
In React Native, we've found a bug with suspense boundaries reverting to the fallback in the following case. The expected behavior (and behavior on web) is as follows:
1. Render a Suspense boundary on initial mount, resolve the promise, show the content.
2. In a transition, update the content of the existing Suspense boundary, suspending again.
3. The UI should continue to show the previous content
4. Resolve the promise, update to the new content.
However on RN, step 3 shows the fallback again. This is unexpected since we're in a transition and the fallback has already revealed.
What's happening is that in step 3 we call completeWork() which in turn calls finalizeContainerChildren(), which updates to use the fallback. However, this isn't committed to the screen since we never call commitRoot() (and therefore don't call replaceContainerChildren()). Instead, we detec that the render exited with status RootSuspendedOnDelay and that the lane was transition-only, so we don't actually commit the fallback.
However, RN currently commits the content it gets in finalizeContainerChildren(), rather than waiting for replaceContainerChildren() from commitRoot(). The original intent was for finalize...() to do layout, and for replace...() to actually commit the updated tree, which would preserve the web behavior.
#30513 is a brute force way to address this by simply moving all the native work from finalize -> replace. What i'm experimenting with in this PR is to skip calling finalizeContainerChildren() if the above conditions hold: if this is a suspended render in a transition, don't bother finalizing children.1 parent 03072a7 commit df27420
File tree
2 files changed
+12
-1
lines changed- packages/react-reconciler/src
2 files changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
164 | 166 | | |
165 | 167 | | |
166 | 168 | | |
| |||
411 | 413 | | |
412 | 414 | | |
413 | 415 | | |
414 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
415 | 422 | | |
416 | 423 | | |
417 | 424 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1939 | 1939 | | |
1940 | 1940 | | |
1941 | 1941 | | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
1942 | 1946 | | |
1943 | 1947 | | |
1944 | 1948 | | |
| |||
0 commit comments