-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Deprecate context object as a consumer and add a warning message #13829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c902bb5
bd3495c
6d7d7c0
773d69d
22f4359
e39a444
40fcddb
4b0c8a7
f174b6e
59917cd
072b0d4
26d6d2c
d058f6e
9149b17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,18 +78,12 @@ export function createContext<T>( | |
| const consumer = { | ||
| $$typeof: REACT_CONTEXT_TYPE, | ||
| _context: context, | ||
| _calculateChangedBits: context._calculateChangedBits, | ||
| Provider: context.Provider, | ||
|
||
| unstable_read: context.unstable_read, | ||
|
||
| }; | ||
| // $FlowFixMe: Flow complains about not setting a value, which is intentional here | ||
| Object.defineProperties(consumer, { | ||
|
||
| _calculateChangedBits: { | ||
| get() { | ||
| return context._calculateChangedBits; | ||
| }, | ||
| set(_calculateChangedBits) { | ||
| context._calculateChangedBits = _calculateChangedBits; | ||
| }, | ||
| }, | ||
| _currentValue: { | ||
| get() { | ||
| return context._currentValue; | ||
|
|
@@ -119,14 +113,6 @@ export function createContext<T>( | |
| return context.Consumer; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if you render Which makes me think: should the warning move into these getters instead? Fire for first getter accessed, ignore the rest. This could also nicely let us warn once per context type.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving the warning into the getters will stop the error from coming up for just using |
||
| }, | ||
| }, | ||
| unstable_read: { | ||
| get() { | ||
| return context.unstable_read; | ||
| }, | ||
| set(unstable_read) { | ||
| context.unstable_read = unstable_read; | ||
| }, | ||
| }, | ||
| }); | ||
| // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty | ||
| context.Consumer = consumer; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd probably call this
Consumer