Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 945 Bytes

File metadata and controls

49 lines (39 loc) · 945 Bytes

inferno/no-unused-state

📝 Disallow definitions of unused state.

Warns you if you have defined a property on the state, but it is not being used anywhere.

Rule Details

Examples of incorrect code for this rule:

class MyComponent extends Inferno.Component {
  state = { foo: 0 };
  render() {
    return <SomeComponent />;
  }
}

var UnusedGetInitialStateTest = createClass({
  getInitialState: function() {
    return { foo: 0 };
  },
  render: function() {
    return <SomeComponent />;
  }
})

Examples of correct code for this rule:

class MyComponent extends Inferno.Component {
  state = { foo: 0 };
  render() {
    return <SomeComponent foo={this.state.foo} />;
  }
}

var UnusedGetInitialStateTest = createClass({
  getInitialState: function() {
    return { foo: 0 };
  },
  render: function() {
    return <SomeComponent foo={this.state.foo} />;
  }
})