-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some modules actually rely on propTypes #70
Comments
Regarding the big picture, I'm wondering if it should be plugin responsibility to know there the transformation is going to be applied. Shouldn't it be in the babel config? Still, that could be a good option for this plugin. |
I see. So many tools - so little time. I grabbed whatever .babelrc is suggested somewhere in react native docs, which is pretty much empty:
Then I added some plugins to cleanup the release build a bit:
I don't care about any cleanup for the |
I don't have much either, I couldn't find any plugin implementing an Otherwise, implementing an |
@oliviertassinari so, maybe it's unnecessary to remove |
I have added Is it safe? section in the README. Yes, it can be dangerous with the |
Implementing an eslint rule sounds like a good path going forward. We have that proposal jsx-eslint/eslint-plugin-react#696. |
Commented there, if it's easy to detect you can just use something like |
I'm gonna start documenting breaking patterns I have seen here. K.OReference in render from an importimport { pick } from 'lodash';
import SomeComponent from './SomeComponent';
export default function AnotherComponent(props) {
const passedProps = pick(props, Object.keys(SomeComponent.propTypes));
return (
<SomeComponent {...passedProps} />
);
}; Reference in propTypes from an importimport {SomeComponent} from './SomeComponent';
const propTypes = {
value: SomeComponent.propTypes.value,
};
export default function AnotherComponent(props) {
return <SomeComponent value={props.value} />;
}
AnotherComponent.propTypes = propTypes; O.K.React nativeimport {View} from 'react-native';
class CustomView extends React.Component {
static propTypes = {
style: View.propTypes.style
};
render() {
return (
<View style={this.props.style}>..</View>
);
}
} I think that a good first iteration would be to look for MemberExpression referencing a I think that an eslint rule is a complementary solution. |
This Babel plugin now throws when encountering the two previous dangerous pattern. |
Even react-router is affected we need a better solution than just documenting it. |
A configurable glob pattern of modules to ignore might work. I'm willing to add in some guard comments around that statement (in react-router), if it would help. |
@timdorr I agree, I think that I'm gonna add an option to skip files inside a
A simple refactorisation can allow avoiding the issue. Are you opened to that option? I can make a PR. |
PRs > Issues. Go right ahead and I'll look at merging it and and pushing out a patch release. |
@oliviertassinari - we transform all our I've been having a hard time ignoring react-router though, what am I missing? ["transform-react-remove-prop-types", {
"ignoreFilenames": ["Router.js"] //["node_modules/react-router"]
}], |
Nevermind, my release is behind. I was getting this through |
Notice that the react-router fix hasn't been released yet. |
Yes, I'm on V3 though (due to relay) and looking to just ignore that one file. BTW - looks like |
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 examplereact-native-vector-icons\lib\icon-button.js
. RemovingpropTypes
then results inI 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 likeisModule
below I check if it's my own file or not and only then removepropTypes
:I thought maybe it's worth adding an extra option to the plugin that would allow to skip 3rd party modules modification if needed.
The text was updated successfully, but these errors were encountered: