Skip to content
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

[Context Api] React 16.6.0 #13465

Closed
jamalsoueidan opened this issue Oct 31, 2018 · 9 comments · Fixed by #13590
Closed

[Context Api] React 16.6.0 #13465

jamalsoueidan opened this issue Oct 31, 2018 · 9 comments · Fixed by #13590
Labels
priority: important This change can make a difference

Comments

@jamalsoueidan
Copy link

I'm getting this warning when I upgraded to the latest react version.

WithStyles(xxx) declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.

This is related to the new context API.

@jamalsoueidan jamalsoueidan changed the title React 16.6.0 [Context Api] React 16.6.0 Oct 31, 2018
@oliviertassinari oliviertassinari added the duplicate This issue or pull request already exists label Oct 31, 2018
@oliviertassinari
Copy link
Member

@jamalsoueidan Thank you for the feedback. I'm closing for #13394.

@AlekzZz
Copy link

AlekzZz commented Oct 31, 2018

@oliviertassinari aren't those 2 separate issues? @jamalsoueidan is having same issue i get, and it is related to using new context property static contextType vs the legacy one used by withStyles, so when both ways are defined, react keeps the new version, while making withStyles to stop working.

@oliviertassinari oliviertassinari added priority: important This change can make a difference and removed duplicate This issue or pull request already exists labels Oct 31, 2018
@oliviertassinari oliviertassinari self-assigned this Oct 31, 2018
@oliviertassinari
Copy link
Member

@AlekzZz I haven't realized it's breaking everything. Ok, we have been buying some time (multiple months) but not updating the old context API usage. It's time!

@jamalsoueidan
Copy link
Author

@AlekzZz correct 👍

@jamalsoueidan
Copy link
Author

Is it fixed @oliviertassinari so I can upgrade material ui :) ?

@jamalsoueidan
Copy link
Author

Close?

@eps1lon
Copy link
Member

eps1lon commented Nov 14, 2018

@jamalsoueidan This should still be an issue since withStyles is still using the deprecated context API. Can you confirm that the message WithStyles(xxx) declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored. is not appearing anymore?

@oliviertassinari
Copy link
Member

oliviertassinari commented Nov 14, 2018

We should have been taken care of all the usages of the old react context usage! ✨ @eps1lon 👏

@eps1lon
Copy link
Member

eps1lon commented Nov 26, 2018

I think this originated in hoist-non-react-statics which only stopped hoisting contextType in hoist-non-react-statics@3.1.0. Before hoist-non-react-statics@3.1.0 withStyles would hoist contextType of the decorated component into the WithStyles component which uses contextTypes (heed the plural form). This would create a component with contextType and contextTypes which would create the reported error message.

So this was actually resolved once people updated their dependencies after hoist-non-react-statics@3.1.0 was released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: important This change can make a difference
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants