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

react/prop-types false negative for dynamic object access? #818

Closed
amilajack opened this issue Sep 10, 2016 · 2 comments
Closed

react/prop-types false negative for dynamic object access? #818

amilajack opened this issue Sep 10, 2016 · 2 comments
Labels

Comments

@amilajack
Copy link
Contributor

amilajack commented Sep 10, 2016

class Example extends Component {
  examplFn() {
    const type = 'items';
    const { options } = this.props[type] // <-- items.options is missing in props validation
  }
  // ...
}


Example.propTypes = {
  items: PropTypes.shape({
    options: PropTypes.arrayOf(PropTypes.string)
  }).isRequired
}

I'm assuming this isn't by design.

@lencioni lencioni added the bug label Sep 16, 2016
@lencioni
Copy link
Collaborator

lencioni commented Sep 16, 2016

I think we could probably fix this for simple cases, but more complex cases will either be impossible or very difficult. I'd be happy to review a PR that fixes this, but I'm not entirely sure it is worth the effort to implement.

@EvHaus EvHaus self-assigned this Oct 1, 2016
@EvHaus EvHaus removed their assignment Jan 7, 2020
@ljharb
Copy link
Member

ljharb commented Feb 2, 2022

PRs that improve propTypes detection are exceedingly welcome, but I don't think leaving this issue open is going to help the likelihood of that.

@ljharb ljharb closed this as completed Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants