dillon1000/react

Commit

stash the component stack on the thrown value and reuse (#25790)

ErrorBoundaries are currently not fully composable. The reason is if you
decide your boundary cannot handle a particular error and rethrow it to
higher boundary the React runtime does not understand that this throw is
a forward and it recreates the component stack from the Boundary
position. This loses fidelity and is especially bad if the boundary is
limited it what it handles and high up in the component tree.

This implementation uses a WeakMap to store component stacks for values
that are objects. If an error is rethrown from an ErrorBoundary the
stack will be pulled from the map if it exists. This doesn't work for
thrown primitives but this is uncommon and stashing the stack on the
primitive also wouldn't work
Browse files
Changed paths3 files
First-parent comparison
M packages/react-reconciler/src/ReactCapturedValue.js ModifiedM packages/react-reconciler/src/ReactFiberBeginWork.js ModifiedA packages/react-reconciler/src/__tests__/ReactErrorStacks-test.js Added
Patch

Files changed

Rendering syntax-highlighted changes…