MCPcopy Create free account
hub / github.com/plotly/dash / readContext

Function readContext

dash/deps/react-dom@18.3.1.js:14372–14408  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

14370 }
14371 }
14372 function readContext(context) {
14373 {
14374 // This warning would fire if you read context inside a Hook like useMemo.
14375 // Unlike the class check below, it's not enforced in production for perf.
14376 if (isDisallowedContextReadInDEV) {
14377 error('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().');
14378 }
14379 }
14380
14381 var value = context._currentValue ;
14382
14383 if (lastFullyObservedContext === context) ; else {
14384 var contextItem = {
14385 context: context,
14386 memoizedValue: value,
14387 next: null
14388 };
14389
14390 if (lastContextDependency === null) {
14391 if (currentlyRenderingFiber === null) {
14392 throw new Error('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().');
14393 } // This is the first dependency for this component. Create a new list.
14394
14395
14396 lastContextDependency = contextItem;
14397 currentlyRenderingFiber.dependencies = {
14398 lanes: NoLanes,
14399 firstContext: contextItem
14400 };
14401 } else {
14402 // Append a new context item.
14403 lastContextDependency = lastContextDependency.next = contextItem;
14404 }
14405 }
14406
14407 return value;
14408 }
14409
14410 // render. When this render exits, either because it finishes or because it is
14411 // interrupted, the interleaved updates will be transferred onto the main part

Callers 6

constructClassInstanceFunction · 0.70
mountClassInstanceFunction · 0.70
resumeMountClassInstanceFunction · 0.70
updateClassInstanceFunction · 0.70
updateContextConsumerFunction · 0.70

Calls 1

errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…