ReactContext.js — react Source File
Architecture documentation for ReactContext.js, a javascript file in the react codebase. 2 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR c0f9756e_36f0_b861_899d_decc8aef8f64["ReactContext.js"] e1e1de60_2be4_0643_45fb_e2c306735427["ReactSymbols"] c0f9756e_36f0_b861_899d_decc8aef8f64 --> e1e1de60_2be4_0643_45fb_e2c306735427 d8f20c67_f5fa_0f0a_c967_c41fd9ffce07["ReactTypes"] c0f9756e_36f0_b861_899d_decc8aef8f64 --> d8f20c67_f5fa_0f0a_c967_c41fd9ffce07 ffdf54f0_7e34_f1e9_1504_9dbadb0fbac5["ReactClient.js"] ffdf54f0_7e34_f1e9_1504_9dbadb0fbac5 --> c0f9756e_36f0_b861_899d_decc8aef8f64 style c0f9756e_36f0_b861_899d_decc8aef8f64 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 {REACT_CONSUMER_TYPE, REACT_CONTEXT_TYPE} from 'shared/ReactSymbols';
import type {ReactContext} from 'shared/ReactTypes';
export function createContext<T>(defaultValue: T): ReactContext<T> {
// TODO: Second argument used to be an optional `calculateChangedBits`
// function. Warn to reserve for future use?
const context: ReactContext<T> = {
$$typeof: REACT_CONTEXT_TYPE,
// As a workaround to support multiple concurrent renderers, we categorize
// some renderers as primary and others as secondary. We only expect
// there to be two concurrent renderers at most: React Native (primary) and
// Fabric (secondary); React DOM (primary) and React ART (secondary).
// Secondary renderers store their context values on separate fields.
_currentValue: defaultValue,
_currentValue2: defaultValue,
// Used to track how many concurrent renderers this context currently
// supports within in a single renderer. Such as parallel server rendering.
_threadCount: 0,
// These are circular
Provider: (null: any),
Consumer: (null: any),
};
context.Provider = context;
context.Consumer = {
$$typeof: REACT_CONSUMER_TYPE,
_context: context,
};
if (__DEV__) {
context._currentRenderer = null;
context._currentRenderer2 = null;
}
return context;
}
Domain
Dependencies
- ReactSymbols
- ReactTypes
Imported By
Source
Frequently Asked Questions
What does ReactContext.js do?
ReactContext.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactContext.js depend on?
ReactContext.js imports 2 module(s): ReactSymbols, ReactTypes.
What files import ReactContext.js?
ReactContext.js is imported by 1 file(s): ReactClient.js.
Where is ReactContext.js in the architecture?
ReactContext.js is located at packages/react/src/ReactContext.js (domain: BabelCompiler, directory: packages/react/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free