Prefix _context property on returned ReactContext from createContext - it's private (#12501)
Mateusz Burzyński committed
Apr 3, 2018 at 02:47 UTC
ba245f6f9b0bf31c2ebff5c087c21bcae111e6c3
5 files changed
+7
-7
packages/react-dom/src/server/ReactPartialRenderer.js
+2
-2
@@ -675,7 +675,7 @@ class ReactDOMServerRenderer {
675
pushProvider<T>(provider: ReactProvider<T>): void {
676
this.providerIndex += 1;
677
this.providerStack[this.providerIndex] = provider;
678
- const context: ReactContext<any> = provider.type.context;
678
+ const context: ReactContext<any> = provider.type._context;
679
context._currentValue = provider.props.value;
680
}
681
@@ -689,7 +689,7 @@ class ReactDOMServerRenderer {
689
}
690
this.providerStack[this.providerIndex] = null;
691
this.providerIndex -= 1;
692
- const context: ReactContext<any> = provider.type.context;
692
+ const context: ReactContext<any> = provider.type._context;
693
if (this.providerIndex < 0) {
694
context._currentValue = context._defaultValue;
695
} else {
packages/react-reconciler/src/ReactFiberBeginWork.js
+1
-1
@@ -868,7 +868,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
868
renderExpirationTime,
869
) {
870
const providerType: ReactProviderType<any> = workInProgress.type;
871
- const context: ReactContext<any> = providerType.context;
871
+ const context: ReactContext<any> = providerType._context;
872
873
const newProps = workInProgress.pendingProps;
874
const oldProps = workInProgress.memoizedProps;
packages/react-reconciler/src/ReactFiberNewContext.js
+2
-2
@@ -32,7 +32,7 @@ export default function(stack: Stack) {
32
}
33
34
function pushProvider(providerFiber: Fiber): void {
35
- const context: ReactContext<any> = providerFiber.type.context;
35
+ const context: ReactContext<any> = providerFiber.type._context;
36
37
push(changedBitsCursor, context._changedBits, providerFiber);
38
push(valueCursor, context._currentValue, providerFiber);
@@ -60,7 +60,7 @@ export default function(stack: Stack) {
60
pop(valueCursor, providerFiber);
61
pop(changedBitsCursor, providerFiber);
62
63
- const context: ReactContext<any> = providerFiber.type.context;
63
+ const context: ReactContext<any> = providerFiber.type._context;
64
context._currentValue = currentValue;
65
context._changedBits = changedBits;
66
}
packages/react/src/ReactContext.js
+1
-1
@@ -44,7 +44,7 @@ export function createContext<T>(
44
45
context.Provider = {
46
$$typeof: REACT_PROVIDER_TYPE,
47
- context,
47
+ _context: context,
48
};
49
context.Consumer = context;
50
packages/shared/ReactTypes.js
+1
-1
@@ -62,7 +62,7 @@ export type ReactProvider<T> = {
62
63
export type ReactProviderType<T> = {
64
$$typeof: Symbol | number,
65
- context: ReactContext<T>,
65
+ _context: ReactContext<T>,
66
};
67
68
export type ReactConsumer<T> = {