mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Prefix _context property on returned ReactContext from createContext - it's private (#12501)
This commit is contained in:
committed by
Dan Abramov
parent
6f2ea73978
commit
ba245f6f9b
+2
-2
@@ -675,7 +675,7 @@ class ReactDOMServerRenderer {
|
||||
pushProvider<T>(provider: ReactProvider<T>): void {
|
||||
this.providerIndex += 1;
|
||||
this.providerStack[this.providerIndex] = provider;
|
||||
const context: ReactContext<any> = provider.type.context;
|
||||
const context: ReactContext<any> = provider.type._context;
|
||||
context._currentValue = provider.props.value;
|
||||
}
|
||||
|
||||
@@ -689,7 +689,7 @@ class ReactDOMServerRenderer {
|
||||
}
|
||||
this.providerStack[this.providerIndex] = null;
|
||||
this.providerIndex -= 1;
|
||||
const context: ReactContext<any> = provider.type.context;
|
||||
const context: ReactContext<any> = provider.type._context;
|
||||
if (this.providerIndex < 0) {
|
||||
context._currentValue = context._defaultValue;
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -868,7 +868,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
|
||||
renderExpirationTime,
|
||||
) {
|
||||
const providerType: ReactProviderType<any> = workInProgress.type;
|
||||
const context: ReactContext<any> = providerType.context;
|
||||
const context: ReactContext<any> = providerType._context;
|
||||
|
||||
const newProps = workInProgress.pendingProps;
|
||||
const oldProps = workInProgress.memoizedProps;
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ export default function(stack: Stack) {
|
||||
}
|
||||
|
||||
function pushProvider(providerFiber: Fiber): void {
|
||||
const context: ReactContext<any> = providerFiber.type.context;
|
||||
const context: ReactContext<any> = providerFiber.type._context;
|
||||
|
||||
push(changedBitsCursor, context._changedBits, providerFiber);
|
||||
push(valueCursor, context._currentValue, providerFiber);
|
||||
@@ -60,7 +60,7 @@ export default function(stack: Stack) {
|
||||
pop(valueCursor, providerFiber);
|
||||
pop(changedBitsCursor, providerFiber);
|
||||
|
||||
const context: ReactContext<any> = providerFiber.type.context;
|
||||
const context: ReactContext<any> = providerFiber.type._context;
|
||||
context._currentValue = currentValue;
|
||||
context._changedBits = changedBits;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export function createContext<T>(
|
||||
|
||||
context.Provider = {
|
||||
$$typeof: REACT_PROVIDER_TYPE,
|
||||
context,
|
||||
_context: context,
|
||||
};
|
||||
context.Consumer = context;
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ export type ReactProvider<T> = {
|
||||
|
||||
export type ReactProviderType<T> = {
|
||||
$$typeof: Symbol | number,
|
||||
context: ReactContext<T>,
|
||||
_context: ReactContext<T>,
|
||||
};
|
||||
|
||||
export type ReactConsumer<T> = {
|
||||
|
||||
Reference in New Issue
Block a user