Skip to content

Fix false positive context warning when using an old React#13850

Merged
gaearon merged 1 commit intofacebook:masterfrom
gaearon:ctx-false-positive
Oct 14, 2018
Merged

Fix false positive context warning when using an old React#13850
gaearon merged 1 commit intofacebook:masterfrom
gaearon:ctx-false-positive

Conversation

@gaearon
Copy link
Collaborator

@gaearon gaearon commented Oct 14, 2018

If you use a newer renderer with an older react package, context Consumer (which is context in older versions) doesn't have the _context field, causing a false positive.

This fixes it by verifying that we're running a version where context and Consumer objects are different.

@gaearon gaearon force-pushed the ctx-false-positive branch from 047c476 to 6b66cf5 Compare October 14, 2018 14:22
@gaearon gaearon requested a review from trueadm October 14, 2018 14:22
// 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) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sizebot
Copy link

sizebot commented Oct 14, 2018

Details of bundled changes.

Comparing: 4773fdf...6b66cf5

scheduler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
scheduler.development.js n/a n/a 0 B 19.17 KB 0 B 5.74 KB UMD_DEV
scheduler.production.min.js n/a n/a 0 B 3.16 KB 0 B 1.53 KB UMD_PROD

Generated by 🚫 dangerJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants