Skip to content

Commit

Permalink
Prefix _context property on returned ReactContext from createContext …
Browse files Browse the repository at this point in the history
…- it's private (#12501)
  • Loading branch information
Andarist authored and gaearon committed Apr 3, 2018
1 parent 6f2ea73 commit ba245f6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactPartialRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberNewContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ReactContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function createContext<T>(

context.Provider = {
$$typeof: REACT_PROVIDER_TYPE,
context,
_context: context,
};
context.Consumer = context;

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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> = {
Expand Down

0 comments on commit ba245f6

Please sign in to comment.