dillon1000/react

Commit

Synchronously restart when an error is thrown during async rendering (#13041)

In async mode, events are interleaved with rendering. If one of those
events mutates state that is later accessed during render, it can lead
to inconsistencies/tearing.

Restarting the render from the root is often sufficient to fix the
inconsistency. We'll flush the restart synchronously to prevent yet
another mutation from happening during an interleaved event.

We'll only restart during an async render. Sync renders are already
sync, so there's no benefit in restarting. (Unless a mutation happens
during the render phase, but we don't support that.)
Browse files
Changed paths9 files
First-parent comparison
M packages/react-reconciler/src/ReactFiberPendingPriority.js ModifiedM packages/react-reconciler/src/ReactFiberRoot.js ModifiedM packages/react-reconciler/src/ReactFiberScheduler.js ModifiedM packages/react-reconciler/src/ReactFiberUnwindWork.js ModifiedM packages/react-reconciler/src/__tests__/ReactIncrementalErrorHandling-test.internal.js ModifiedM packages/react-reconciler/src/__tests__/ReactIncrementalErrorReplay-test.js ModifiedM packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js ModifiedM packages/react-reconciler/src/__tests__/__snapshots__/ReactIncrementalPerf-test.internal.js.snap ModifiedM packages/react/src/__tests__/forwardRef-test.internal.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…