Fix false positive context warning when using an old React#13850
Merged
gaearon merged 1 commit intofacebook:masterfrom Oct 14, 2018
Merged
Fix false positive context warning when using an old React#13850gaearon merged 1 commit intofacebook:masterfrom
gaearon merged 1 commit intofacebook:masterfrom
Conversation
047c476 to
6b66cf5
Compare
gaearon
commented
Oct 14, 2018
| // This may be because it's a Context (rather than a Consumer). | ||
| // Or it may be because it's older React where they're the same thing. | ||
| // We only want to warn if we're sure it's a new React. | ||
| if (context !== context.Consumer) { |
Collaborator
Author
There was a problem hiding this comment.
We know that context itself is not a "new" Consumer because in that case _context wouldn't be undefined. So it's safe to read context.Consumer.
Details of bundled changes.Comparing: 4773fdf...6b66cf5 scheduler
Generated by 🚫 dangerJS |
trueadm
approved these changes
Oct 14, 2018
linjiajian999
pushed a commit
to linjiajian999/react
that referenced
this pull request
Oct 22, 2018
jetoneza
pushed a commit
to jetoneza/react
that referenced
this pull request
Jan 23, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you use a newer renderer with an older
reactpackage, context Consumer (which is context in older versions) doesn't have the_contextfield, causing a false positive.This fixes it by verifying that we're running a version where context and Consumer objects are different.