processChildContext() — react Function Reference
Architecture documentation for the processChildContext() function in ReactFizzLegacyContext.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 0de4544a_f806_f825_c1b6_b15f8acb1ac0["processChildContext()"] 4825696d_2f43_1121_7cc9_951fbe850d0a["ReactFizzLegacyContext.js"] 0de4544a_f806_f825_c1b6_b15f8acb1ac0 -->|defined in| 4825696d_2f43_1121_7cc9_951fbe850d0a style 0de4544a_f806_f825_c1b6_b15f8acb1ac0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-server/src/ReactFizzLegacyContext.js lines 42–83
export function processChildContext(
instance: any,
type: any,
parentContext: Object,
childContextTypes: Object,
): Object {
if (disableLegacyContext) {
return parentContext;
} else {
// TODO (bvaughn) Replace this behavior with an invariant() in the future.
// It has only been added in Fiber to match the (unintentional) behavior in Stack.
if (typeof instance.getChildContext !== 'function') {
if (__DEV__) {
const componentName = getComponentNameFromType(type) || 'Unknown';
if (!warnedAboutMissingGetChildContext[componentName]) {
warnedAboutMissingGetChildContext[componentName] = true;
console.error(
'%s.childContextTypes is specified but there is no getChildContext() method ' +
'on the instance. You can either define getChildContext() on %s or remove ' +
'childContextTypes from it.',
componentName,
componentName,
);
}
}
return parentContext;
}
const childContext = instance.getChildContext();
for (const contextKey in childContext) {
if (!(contextKey in childContextTypes)) {
throw new Error(
`${
getComponentNameFromType(type) || 'Unknown'
}.getChildContext(): key "${contextKey}" is not defined in childContextTypes.`,
);
}
}
return {...parentContext, ...childContext};
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does processChildContext() do?
processChildContext() is a function in the react codebase, defined in packages/react-server/src/ReactFizzLegacyContext.js.
Where is processChildContext() defined?
processChildContext() is defined in packages/react-server/src/ReactFizzLegacyContext.js at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free