Some modules actually rely on propTypes
See original GitHub issueHi,
thank you for the plugin. It works well. I noticed though that some of the RN 3rd party modules rely on propTypes property. See for example react-native-vector-icons\lib\icon-button.js. Removing propTypes then results in
AndroidRuntime: com.facebook.react.common.JavascriptException:
Requested keys of a value that is not an object., stack:
I modified my version of the plugin, so that only files not residing in node_modules are cleaned up preventing this type of crashes. In a function like isModule below I check if it’s my own file or not and only then remove propTypes:
function isModule(scope) {
if (!scope.hub.file.opts) {
return true;
}
var filename = scope.hub.file.opts.filename;
if (!filename) {
return true;
}
return filename.indexOf("node_modules") !== -1;
}
I thought maybe it’s worth adding an extra option to the plugin that would allow to skip 3rd party modules modification if needed.
Issue Analytics
- State:
- Created 7 years ago
- Comments:17 (9 by maintainers)
Top Results From Across the Web
Use imported modules in React propType definitions
As the React devs themselves admit here , there is no one way to define a prop type for a component. Perhaps the...
Read more >How to Use PropTypes in React - freeCodeCamp
We can use PropTypes to validate any data we are receiving from props. But before using it we will have to import it...
Read more >Don't Call PropTypes Warning - React
Nothing changes here. Don't call PropTypes directly. Using PropTypes in any other way than annotating React components with them is no longer supported:....
Read more >propTypes vs typescript types in React components - Medium
Prop types validate's react component's prop types in runtime and provide warnings in browser console if the sent prop is missing or the...
Read more >Invariant Violation: ViewPropTypes has been removed from ...
Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'. ERROR Invariant Violation: Module AppRegistry is not a registered callable ...
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

PRs > Issues. Go right ahead and I’ll look at merging it and and pushing out a patch release.
Yes, I’m on V3 though (due to relay) and looking to just ignore that one file. BTW - looks like
babel-preset-react-optimizeisn’t being maintained and references this project.