Skip to content

react/no-unused-prop-types false positive on destructured props #1002

Closed
@victorias

Description

@victorias

react/no-unused-prop-types thinks that both the onClick and children props are unused even though these are clearly being used:

type Props = {
  onClick: () => void,
  children: any,
};

class Button extends Component {
  props: Props

  render () {
    const { props } = this;
    return (
      <button
        onClick={props.onClick}
      >
        {props.children}
      </button>
    );
  }
}

export default Button;

If I refer to onClick using this.props.onClick or destructure all the props from this.props it works.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions