Skip to content

Shape validation does not recognize deconstructed props attributes #7815

@nwikstrand

Description

@nwikstrand

Bug (?)

Shape validation does not recognize deconstructed props attribute.
'bar.baz' PropType is defined but prop is never used react/no-unused-prop-types

Failing example with deconstructed props:

const Foo = ({bar}) => (
  <div>
    {bar.baz}
  </div>
);

Foo.propTypes = {
  bar: React.PropTypes.shape({
    baz: React.PropTypes.string,
  }),
};

Working example with non deconstructed props:

const Foo = (props) => (
  <div>
    {props.bar.baz}
  </div>
);

Foo.propTypes = {
  bar: React.PropTypes.shape({
    baz: React.PropTypes.string,
  }),
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions