Material-ui: [Context Api] React 16.6.0

Created on 31 Oct 2018  ·  9Comments  ·  Source: mui-org/material-ui

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.

important

Most helpful comment

@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!

All 9 comments

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

@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.

@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!

@AlekzZz correct 👍

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

Close?

@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?

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

I think this originated in hoist-non-react-statics which only stopped hoisting contextType in [email protected]. Before [email protected] 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 [email protected] was released.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ·  3Comments

activatedgeek picture activatedgeek  ·  3Comments

reflog picture reflog  ·  3Comments

pola88 picture pola88  ·  3Comments

ghost picture ghost  ·  3Comments