Giter Site home page Giter Site logo

Comments (4)

oliviertassinari avatar oliviertassinari commented on June 4, 2024

Yeah, that's actually a design decision, have a look at #8

It's also taking a side by only accepting React.Component and Component as class names.
Anything else, like BaseComponent, won't be optimised.

from babel-plugin-transform-react-remove-prop-types.

azasypkin avatar azasypkin commented on June 4, 2024

Ah, I see, thanks for the pointer!

So does it mean that Babel doesn't allow to traverse up the inheritance chain at all or it's just current limitation of the plugin?

from babel-plugin-transform-react-remove-prop-types.

oliviertassinari avatar oliviertassinari commented on June 4, 2024

The thing is, I can't remove the propTypes from any class. I should only do it on a React class component.
I need a heuristic to do so. I relying on the React.Component and Component class names.
That works great in +90% of the cases.
For your specific cases, we could also be looking for a render method and assert that this method is returning a React element.

TL;DR The quick win is to rename your Parent class. The right way to fix this issue would be to improve the heuristic.

P.S. Notice that using inheritance is considered a bad pattern in React. I would rather use composition.

from babel-plugin-transform-react-remove-prop-types.

oliviertassinari avatar oliviertassinari commented on June 4, 2024

This issue is quite old. I haven't seen more need for it. I'm closing it. Thanks for raising your voice.

from babel-plugin-transform-react-remove-prop-types.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.