Skip to content

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

Closed
@GreenGeorge

Description

@GreenGeorge

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions