We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a129259 commit f0befaeCopy full SHA for f0befae
packages/react-reconciler/src/ReactFiberNewContext.js
@@ -330,8 +330,10 @@ export function readContext<T>(
330
if (lastContextDependency === null) {
331
invariant(
332
currentlyRenderingFiber !== null,
333
- 'Context can only be read while React is ' +
334
- 'rendering, e.g. inside the render method or getDerivedStateFromProps.',
+ 'Context can only be read while React is rendering. ' +
+ 'In classes, you can read it in the render method or getDerivedStateFromProps. ' +
335
+ 'In function components, you can read it directly in the function body, but not ' +
336
+ 'inside Hooks like useReducer() or useMemo().',
337
);
338
339
// This is the first dependency for this component. Create a new list.
0 commit comments