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
  • Loading branch information
Andarist committed Mar 31, 2018
1 parent fa8e678 commit 9378793
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 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

0 comments on commit 9378793

Please sign in to comment.