Skip to content

Invalid react/no-direct-mutation-state in constructor #1382

Closed
@emmanuelgautier

Description

@emmanuelgautier

In the following special case, the react/no-direct-mutation-state rule throw an invalid error

class OneComponent extends Component {
  constructor() {
    super();

    class AnotherComponent extends Component {
      constructor() {
        super();
      }
    }

    this.state = {};
  }
}

A better way is to not declare a component into another component constructor but that is an invalid linter error .

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