Skip to content

False positive on react/no-unused-prop-types #1764

Closed
@guioconnor

Description

@guioconnor

I came across some code looking like this where myProp was reportedly not being used, even though it was.

render() {
    const { props } = this;
    const { myProp } = props;
    someFunction(myProp)
}

MyComponent.propTypes = {
  myProp: PropTypes.number,
};

It seems the double desctructure confused the rule because a change to the code below fixed it.

render() {
    const { myProp } = this.props;
    someFunction(myProp)
}

I think it may be similar to #933, except this one is not such an anti-pattern. It looks very strange on my reduced version, but in a context with more variables can be more natural.

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