@samitouri / QOS-React-2 / commits / f0befae657

Tweak context invariant message (#14671)

Dan Abramov committed Jan 23, 2019 at 16:14 UTC f0befae657e2470f966235d2963179a9a1f948bd
1 file changed +4 -2
packages/react-reconciler/src/ReactFiberNewContext.js
+4 -2
@@ -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.',
333 + 'Context can only be read while React is rendering. ' +
334 + '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.