-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Warn about legacy context when legacy context is not disabled #30297
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
64eb3f3
to
d74094d
Compare
74fa741
to
59752f7
Compare
Lol, quite a whack-a-mole, but tests pass now. Wish it was easier to see all the tests failing on the last run. Let me know if that makes sense, ready for review! |
@@ -426,6 +426,22 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) { | |||
name, | |||
); | |||
} | |||
if (ctor.childContextTypes && !didWarnAboutChildContextTypes.has(ctor)) { |
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.
Code copied from line 392-407 above
@@ -403,6 +403,22 @@ function checkClassInstance(instance: any, ctor: any, newProps: any) { | |||
name, | |||
); | |||
} | |||
if (ctor.childContextTypes && !didWarnAboutChildContextTypes.has(ctor)) { |
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.
copied from line 369-384 above
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.
Link to docs from the error: https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-removing-legacy-context?
Though the docs are missing that legacy context was also supported on function Components.
I didn't even know that before seeing the code. Not sure if it was ever broadly communicated as legacy context was deprecated around the time of introduction of function components, IIRC. |
For environments that still have legacy contexts available, this adds a warning to make the remaining call sites easier to locate and encourage upgrades.
For environments that still have legacy contexts available, this adds a warning to make the remaining call sites easier to locate and encourage upgrades. DiffTrain build for commit 378b305.
For environments that still have legacy contexts available, this adds a warning to make the remaining call sites easier to locate and encourage upgrades.