dillon1000/react

Commit

Improve React error message when mutable sources are mutated during render (#20665)

Changed previous error message from:
> Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.

To:
> Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue.

Also added a DEV only warning about the unsafe side effect:
> A mutable source was mutated while the %s component was rendering. This is not supported. Move any mutations into event handlers or effects.

I think this is the best we can do without adding production overhead that we'd probably prefer to avoid.
Browse files
Changed paths6 files
First-parent comparison
M packages/react-reconciler/src/ReactFiberHooks.new.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.old.js ModifiedM packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js ModifiedM packages/react/src/ReactMutableSource.js ModifiedM packages/shared/ReactTypes.js ModifiedM scripts/error-codes/codes.json Modified
Patch

Files changed

Rendering syntax-highlighted changes…