Skip to content

no-unused-state doesn't respect usage in gDSFP #2061

Closed
@hornta

Description

@hornta
class Foo extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      foo: props.foo // is reporting "[eslint] Unused state field: 'foo' [react/no-unused-state]"
    };
  }

  static getDerivedStateFromProps(props, state) {
    
    // am using state.foo
    if (state.foo) {
      return { bar: 123 };
    }

    return null;
  }
}

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