Instead of removing propTypes, replace with empty object
See original GitHub issueRemoving propTypes entirely is causing issues with third party dependencies that need them to be defined. This was causing issues when using react-native-web.
It was brought up that replacing propTypes with an empty object would have the effects of not needing those definitions, while allowing libraries to reference undefined properties on propTypes and prevent cannot read [name] of undefined errors.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:18 (5 by maintainers)
Top Results From Across the Web
Is there a way in React to change a prop type to avoid ...
I'm wondering if there's a way to change a prop type if the one that is being passed isn't of the type expected....
Read more >prop-types
Runtime type checking for React props and similar objects. ... To load a specific version of prop-types replace 15.6.0 with the version ...
Read more >Typescript & React: Manipulating Prop Types | by Ross Bulat
Let's explore how to do this using the Exclude and Pick helper types in Typescript alongside extends and keyof type operators. Removing unneeded...
Read more >Learn React PropTypes In 13 Minutes - YouTube
Learn React Today Course: https://courses.webdevsimplified.com/learn-react-todayWith React it is very easy to accidentally pass incorrect ...
Read more >How To Style React Components
Delete the line import logo from './logo.svg'; . Then replace everything in the return statement to return a set of empty tags: <></>...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The purpose of the plugin is to remove prop types. That’s what it should do. If a 3rd party library is using the plugin but expecting prop types … then that’s their issue.
Using proper babel environments one can define the necessary requirements (dist should use this plugin, but development, normal imports should not). There are numerous examples of vendors using this properly allowing prop types in development, internal builds, but excluding for dist versions. Please see those.
[close issue please]
Here’s my attempt at replacing propTypes with an object. I’ve been testing it with my
react-native-webapp, and it seems to work perfectly.I’m still finding my way around the Babel AST, so the code is not very good. But it works well for me.