question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Some modules actually rely on propTypes

See original GitHub issue

Hi,

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:closed
  • Created 7 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
timdorrcommented, Feb 9, 2017

PRs > Issues. Go right ahead and I’ll look at merging it and and pushing out a patch release.

0reactions
rosskevincommented, Mar 2, 2017

Yes, I’m on V3 though (due to relay) and looking to just ignore that one file. BTW - looks like babel-preset-react-optimize isn’t being maintained and references this project.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found