Skip to content

Commit

Permalink
Add ctx._context for backwards compat
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Feb 3, 2024
1 parent 9fba3da commit 400adc8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/react/src/ReactContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
// These are circular
Provider: (null: any),
Consumer: (null: any),
// Temporary for backwards compat:
_context: null,
};

context.Provider = context;
Expand All @@ -38,6 +40,10 @@ export function createContext<T>(defaultValue: T): ReactContext<T> {
_context: context,
};

// Some tooling (e.g. DevTools) may assume that context.Provider._context === context.
// Keep that true for now to avoid excessive breakage.
context._context = context;

if (__DEV__) {
context._currentRenderer = null;
context._currentRenderer2 = null;
Expand Down

0 comments on commit 400adc8

Please sign in to comment.