ReactFizzLegacyContext.js — react Source File
Architecture documentation for ReactFizzLegacyContext.js, a javascript file in the react codebase. 2 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR 4825696d_2f43_1121_7cc9_951fbe850d0a["ReactFizzLegacyContext.js"] 8344de1b_978c_be0f_eebd_38ccc4962a93["ReactFeatureFlags"] 4825696d_2f43_1121_7cc9_951fbe850d0a --> 8344de1b_978c_be0f_eebd_38ccc4962a93 3c38cd62_f628_0c7b_096c_856305caeada["getComponentNameFromType"] 4825696d_2f43_1121_7cc9_951fbe850d0a --> 3c38cd62_f628_0c7b_096c_856305caeada 8f850c79_0562_f37f_80ff_563c50cd0996["ReactFizzClassComponent.js"] 8f850c79_0562_f37f_80ff_563c50cd0996 --> 4825696d_2f43_1121_7cc9_951fbe850d0a 1b694821_5816_1762_7c98_f0727a09e732["ReactFizzServer.js"] 1b694821_5816_1762_7c98_f0727a09e732 --> 4825696d_2f43_1121_7cc9_951fbe850d0a style 4825696d_2f43_1121_7cc9_951fbe850d0a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import {disableLegacyContext} from 'shared/ReactFeatureFlags';
import getComponentNameFromType from 'shared/getComponentNameFromType';
let warnedAboutMissingGetChildContext;
if (__DEV__) {
warnedAboutMissingGetChildContext = ({}: {[string]: boolean});
}
export const emptyContextObject: {} = {};
if (__DEV__) {
Object.freeze(emptyContextObject);
}
export function getMaskedContext(type: any, unmaskedContext: Object): Object {
if (disableLegacyContext) {
return emptyContextObject;
} else {
const contextTypes = type.contextTypes;
if (!contextTypes) {
return emptyContextObject;
}
const context: {[string]: $FlowFixMe} = {};
for (const key in contextTypes) {
context[key] = unmaskedContext[key];
}
return context;
}
}
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
Functions
Dependencies
- ReactFeatureFlags
- getComponentNameFromType
Imported By
Source
Frequently Asked Questions
What does ReactFizzLegacyContext.js do?
ReactFizzLegacyContext.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in ReactFizzLegacyContext.js?
ReactFizzLegacyContext.js defines 2 function(s): getMaskedContext, processChildContext.
What does ReactFizzLegacyContext.js depend on?
ReactFizzLegacyContext.js imports 2 module(s): ReactFeatureFlags, getComponentNameFromType.
What files import ReactFizzLegacyContext.js?
ReactFizzLegacyContext.js is imported by 2 file(s): ReactFizzClassComponent.js, ReactFizzServer.js.
Where is ReactFizzLegacyContext.js in the architecture?
ReactFizzLegacyContext.js is located at packages/react-server/src/ReactFizzLegacyContext.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-server/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free