Skip to content

Commit ba245f6

Browse files
Andaristgaearon
authored andcommitted
Prefix _context property on returned ReactContext from createContext - it's private (#12501)
1 parent 6f2ea73 commit ba245f6

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

packages/react-dom/src/server/ReactPartialRenderer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ class ReactDOMServerRenderer {
675675
pushProvider<T>(provider: ReactProvider<T>): void {
676676
this.providerIndex += 1;
677677
this.providerStack[this.providerIndex] = provider;
678-
const context: ReactContext<any> = provider.type.context;
678+
const context: ReactContext<any> = provider.type._context;
679679
context._currentValue = provider.props.value;
680680
}
681681

@@ -689,7 +689,7 @@ class ReactDOMServerRenderer {
689689
}
690690
this.providerStack[this.providerIndex] = null;
691691
this.providerIndex -= 1;
692-
const context: ReactContext<any> = provider.type.context;
692+
const context: ReactContext<any> = provider.type._context;
693693
if (this.providerIndex < 0) {
694694
context._currentValue = context._defaultValue;
695695
} else {

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
868868
renderExpirationTime,
869869
) {
870870
const providerType: ReactProviderType<any> = workInProgress.type;
871-
const context: ReactContext<any> = providerType.context;
871+
const context: ReactContext<any> = providerType._context;
872872

873873
const newProps = workInProgress.pendingProps;
874874
const oldProps = workInProgress.memoizedProps;

packages/react-reconciler/src/ReactFiberNewContext.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export default function(stack: Stack) {
3232
}
3333

3434
function pushProvider(providerFiber: Fiber): void {
35-
const context: ReactContext<any> = providerFiber.type.context;
35+
const context: ReactContext<any> = providerFiber.type._context;
3636

3737
push(changedBitsCursor, context._changedBits, providerFiber);
3838
push(valueCursor, context._currentValue, providerFiber);
@@ -60,7 +60,7 @@ export default function(stack: Stack) {
6060
pop(valueCursor, providerFiber);
6161
pop(changedBitsCursor, providerFiber);
6262

63-
const context: ReactContext<any> = providerFiber.type.context;
63+
const context: ReactContext<any> = providerFiber.type._context;
6464
context._currentValue = currentValue;
6565
context._changedBits = changedBits;
6666
}

packages/react/src/ReactContext.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function createContext<T>(
4444

4545
context.Provider = {
4646
$$typeof: REACT_PROVIDER_TYPE,
47-
context,
47+
_context: context,
4848
};
4949
context.Consumer = context;
5050

packages/shared/ReactTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export type ReactProvider<T> = {
6262

6363
export type ReactProviderType<T> = {
6464
$$typeof: Symbol | number,
65-
context: ReactContext<T>,
65+
_context: ReactContext<T>,
6666
};
6767

6868
export type ReactConsumer<T> = {

0 commit comments

Comments
 (0)