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

Destructuring values from props is not recognized by proptypes inside PropTypes.shape #851

Closed
GreenGeorge opened this issue Sep 18, 2016 · 2 comments
Labels

Comments

@GreenGeorge
Copy link

GreenGeorge commented Sep 18, 2016

This is similar to #782 which actually works properly for me, what doesn't work is when the proptypes are inside shape() :

const Person = ({ person }) =>
  <h1>{ person.name }</h1>;
Person.propTypes = {
  person = React.PropTypes.shape({
    name: React.PropTypes.string, 
    // eslint error 'person.name' PropType is defined but prop is never used
    // error also pops up on stateful components
  }),
};

It works fine when i dont destructure

const Person = props =>
  <h1>{ props.person.name }</h1>;  // no eslint error
@batjko
Copy link

batjko commented Sep 27, 2016

Just found the same issue.
But it still won't work if I replace the destructuring of the function argument, e.g.:
image

(Before that, I just used function SideMenuItems({menuItems}) instead. Same lint errors)

@EvHaus
Copy link
Collaborator

EvHaus commented Oct 1, 2016

The no-unused-prop-types rule does not support shape props at the moment as such detection is very difficult. If you use shape props, I recommend setting the skipShapeProps option to true on the rule.

Duplicate of #819. Will track further discussion of shape props there.

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