dillon1000/react

Commit

Disallow reading context during useMemo etc (#14648)

* Disallow reading context during useMemo etc

* Continue allowing readContext() in classes and context consumers

The previous commit check was too broad and incorrectly restricted classes from calling readContext(). This check is more precise and only targets components that are Hook-capable. It exploits the fact that `renderExpirationTime` is never `NoWork` after `renderWithHooks` -- something we already rely on.
Browse files
Changed paths4 files
First-parent comparison
M packages/react-reconciler/src/ReactFiberClassComponent.js ModifiedM packages/react-reconciler/src/ReactFiberDispatcher.js ModifiedM packages/react-reconciler/src/ReactFiberHooks.js ModifiedM packages/react-reconciler/src/__tests__/ReactHooks-test.internal.js Modified
Patch

Files changed

Rendering syntax-highlighted changes…