Skip to content

Commit

Permalink
Tweak context invariant message (#14671)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Jan 23, 2019
1 parent a129259 commit f0befae
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react-reconciler/src/ReactFiberNewContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,10 @@ export function readContext<T>(
if (lastContextDependency === null) {
invariant(
currentlyRenderingFiber !== null,
'Context can only be read while React is ' +
'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. ' +
'In function components, you can read it directly in the function body, but not ' +
'inside Hooks like useReducer() or useMemo().',
);

// This is the first dependency for this component. Create a new list.
Expand Down

0 comments on commit f0befae

Please sign in to comment.