oliviertassinari / babel-plugin-transform-react-remove-prop-types

Remove unnecessary React propTypes from the production build. :balloon:
MIT License
897 stars 61 forks source link

Ability to remove `contextTypes` #173

Closed eugef closed 5 years ago

eugef commented 5 years ago

Would be nice to remove static contextTypes from the components as well.

According to React documentation this static field is not required, only static contextType (singular form here!) is needed https://reactjs.org/docs/context.html#classcontexttype

oliviertassinari commented 5 years ago

It's a duplicate of #77.

oliviertassinari commented 5 years ago

As for the new context API, it can't be removed.

eugef commented 5 years ago

@oliviertassinari I double checked React 16 documentation about Context API and contextTypes are not mentioned there at all. I am also using Context API without defining any contextTypes and it works as expected.

The only static field that is required for Context API is contextType https://reactjs.org/docs/context.html#classcontexttype

Please reconsider either re-opening this issue or PR #77

oliviertassinari commented 5 years ago

@eugef I don't understand.

eugef commented 5 years ago

With new Context API it is safe to remove static contextTypes because this filed is not required anymore

oliviertassinari commented 5 years ago

contextTypes is a legacy API, you are not supposed to use it in the first place.