-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Make prop-types work when renaming this.props #810
Comments
Since we only use the AST it's very difficult to follow variable reassignments and making it would add a lot of complexity to the rules. In your case I suggest you to use destructuring instead which is handled by the rule: class TestComponent extends Component {
render() {
let {name} = this.props;
return (
<div>Hello {name} </div>
);
}
} |
Why would this be difficult? The only thing that is required is that a list of aliases should be kept. |
@yannickcr this is not work , if the name is a object , will still get warning |
@mydearxym What warning are you taking about? With destructuring you correctly get the @JelteF if you have a solution feel free to submit a PR 😃 |
@yannickcr what i mean is if name is an object : class TestComponent extends Component {
render() {
let {name: { firstName }} = this.props;
return (
<div>Hello {firstName} </div>
);
}
}
TestComponent.propTypes = {
name: React.PropTypes.shape({
firstName: React.PropTypes.string // warning , defined but never used
})
}; |
@mydearxym ok, seems you are talking about the (I am aware of the false positives in |
yes is about |
I think it is handy for non stateless components with lots of properties to do something like this:
This does not trigger the prop-types warning though. Would it be possible to make that work?
The text was updated successfully, but these errors were encountered: