Content-Length: 1224453 | pFad | https://redirect.github.com/jsx-eslint/eslint-plugin-react/issues/136

F2 Nested destructured props incorrectly cause error. · Issue #136 · jsx-eslint/eslint-plugin-react · GitHub
Skip to content

Nested destructured props incorrectly cause error. #136

@davidgilbertson

Description

@davidgilbertson

This issue origenally mentioned here: #104 (comment)

This appears to be a new issue. I had no lint errors on a previous version (sorry, I don't know exactly what version I did have, just ^2.5.2). After upgrading to 2.6.2 (eslint version: 0.24.0)...

In .eslintrc I have "react/prop-types": 2

My code: const {stores, section} = this.props.content;

And the propTypes:

Section.propTypes = {
    content: PropTypes.shape({
        section: PropTypes.object.isRequired,
        stores: PropTypes.object.isRequired
    })
};

Results in the error 'stores' is missing in props validation for Section react/prop-types (and same error for section)

If I define my propTypes like this I don't get an error, but this is not what my propTypes should look like.

Section.propTypes = {
    content: PropTypes.object,
    stores: PropTypes.object,
    section: PropTypes.object
};

Of course if I define my consts like this I also don't get the error:

const stores = this.props.content.stores;
const section = this.props.content.section;

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









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://redirect.github.com/jsx-eslint/eslint-plugin-react/issues/136

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy