MCPcopy
hub / github.com/react/react / getUnmaskedContext

Function getUnmaskedContext

packages/react-reconciler/src/ReactFiberLegacyContext.js:40–57  ·  view source on GitHub ↗
(
  workInProgress: Fiber,
  Component: Function,
  didPushOwnContextIfProvider: boolean,
)

Source from the content-addressed store, hash-verified

38let previousContext: Object = emptyContextObject;
39
40function getUnmaskedContext(
41 workInProgress: Fiber,
42 Component: Function,
43 didPushOwnContextIfProvider: boolean,
44): Object {
45 if (disableLegacyContext) {
46 return emptyContextObject;
47 } else {
48 if (didPushOwnContextIfProvider && isContextProvider(Component)) {
49 // If the fiber is a context provider itself, when we read its context
50 // we may have already pushed its own child context on the stack. A context
51 // provider should not "see" its own child context. Therefore we read the
52 // previous (parent) context instead for a context provider.
53 return previousContext;
54 }
55 return contextStackCursor.current;
56 }
57}
58
59function cacheContext(
60 workInProgress: Fiber,

Callers 6

updateFunctionComponentFunction · 0.90
replayBeginWorkFunction · 0.90
constructClassInstanceFunction · 0.90
mountClassInstanceFunction · 0.90
resumeMountClassInstanceFunction · 0.90
updateClassInstanceFunction · 0.90

Calls 1

isContextProviderFunction · 0.70

Tested by

no test coverage detected