-
Notifications
You must be signed in to change notification settings - Fork 45.6k
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
More useful DEV error message when lazy-rendering Context Provider #27168
More useful DEV error message when lazy-rendering Context Provider #27168
Conversation
Comparing: 98f3f14...4ad8f61 Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant changes) |
94fa71d
to
526a39f
Compare
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.
Demo.
4bdb8eb
to
65e292f
Compare
if (Component !== null && typeof Component === 'object') { | ||
if (Component.$$typeof === REACT_LAZY_TYPE) { | ||
hint = ' Did you wrap a component in React.lazy() more than once?'; | ||
} else if (Component.type.$$typeof === REACT_PROVIDER_TYPE) { |
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.
} else if (Component.type.$$typeof === REACT_PROVIDER_TYPE) { | |
} else if (Component.type?.$$typeof === REACT_PROVIDER_TYPE) { |
Defensive optional chaining in case Component.type
doesn't exist
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.
This seems to fail the tests
09e9cec
to
4ad8f61
Compare
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. |
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you! |
Summary
If you render a
createContext().Provider
from alazy()
, the error message is difficult to understand:This PR adds a DEV-time hint, following the pattern of the existing one for double-lazy():
How did you test this change?
Added a new test and ran
yarn test
.