Skip to content

Destructuring values from this.<anything> in componentDidUpdate causes prop-types errors #2017

Closed
@ThiefMaster

Description

@ThiefMaster

Note: This only happens with master, not with the latest stable release.

error 'state.bar' is missing in props validation react/prop-types

Example code:

class Test extends React.Component {
    componentDidUpdate() {
        const {bar} = this.state;
        console.log(bar);
    }

    render() {
        return null;
    }
}
$ npx eslint test.js

/home/adrian/dev/indico/src/test.js
  1:1   error  This module could be parsed as a valid script  import/unambiguous
  1:7   error  'Test' is defined but never used               no-unused-vars
  1:20  error  'React' is not defined                         no-undef
  3:16  error  'state.bar' is missing in props validation     react/prop-types

✖ 4 problems (4 errors, 0 warnings)

Disregard the first three errors; I just couldn't be bothered to add the imports etc to the test file - the 4th error is not related to those.

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