MCPcopy Index your code
hub / github.com/react/react / readContext

Function readContext

packages/react-reconciler/src/ReactFiberNewContext.js:502–516  ·  view source on GitHub ↗
(context: ReactContext<T>)

Source from the content-addressed store, hash-verified

500}
501
502export function readContext<T>(context: ReactContext<T>): T {
503 if (__DEV__) {
504 // This warning would fire if you read context inside a Hook like useMemo.
505 // Unlike the class check below, it's not enforced in production for perf.
506 if (isDisallowedContextReadInDEV) {
507 console.error(
508 'Context can only be read while React is rendering. ' +
509 'In classes, you can read it in the render method or getDerivedStateFromProps. ' +
510 'In function components, you can read it directly in the function body, but not ' +
511 'inside Hooks like useReducer() or useMemo().',
512 );
513 }
514 }
515 return readContextForConsumer(currentlyRenderingFiber, context);
516}
517
518export function readContextDuringReconciliation<T>(
519 consumer: Fiber,

Callers 11

updateCacheComponentFunction · 0.90
updateContextConsumerFunction · 0.90
ReactFiberHooks.jsFile · 0.90
readContextFunction · 0.90
useContextFunction · 0.90
getCacheForTypeFunction · 0.90
cacheSignalFunction · 0.90
constructClassInstanceFunction · 0.90
mountClassInstanceFunction · 0.90
resumeMountClassInstanceFunction · 0.90
updateClassInstanceFunction · 0.90

Calls 2

readContextForConsumerFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected