Skip to content
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

Rule prop-types should include nextProps checking in shouldComponentUpdate #1684

Closed
amerryma opened this issue Feb 8, 2018 · 1 comment
Closed

Comments

@amerryma
Copy link
Contributor

amerryma commented Feb 8, 2018

Consider this example:

class Hello extends Component {
  static propTypes = {
    bar: PropTypes.func
  }
  shouldComponentUpdate(nextProps) {
    return nextProps.foo !== null
  }
  render() {
    return <div bar={this.props.bar} />;
  }
}

This is a case where we want to check to make sure that foo is properly defined in propTypes. I think this case should be included in the prop-type rule. Any thoughts?

Please refer to my comment here: #1636 (comment)

I've made the changes in a forked repo and seems to work just fine. If we wanted to get this in, I'd need some help with the test cases but here is my fork: https://github.com/mindspacepdx/eslint-plugin-react/tree/am-should-component-update

@ljharb
Copy link
Member

ljharb commented Feb 9, 2018

A PR would be great :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants