// update variants React.createClass({ render: function() { this.setState({}); // NOT OK this.replaceState({}); // NOT OK this.forceUpdate({}); // NOT OK return
} }); // indirect call, in ES6 class class MyClass1 extends React.Component { constructor(props) { super(props); } render() { this.indirectUpdate(); // NOT OK this.veryIndirectUpdate(); // NOT OK return } indirectUpdate() { this.setState({}); } veryIndirectUpdate() { this.lessIndirectUpdate(); } lessIndirectUpdate() { this.setState({}); } } // definiteness variants React.createClass({ render: function() { this.setState({}); // NOT OK }, componentDidUpdate: function() { this.setState({}); // NOT OK if (cond) { this.setState({}); // OK } }, shouldComponentUpdate: function() { this.setState({}); // NOT OK if (cond) { this.setState({}); // OK } }, componentWillUpdate: function() { this.setState({}); // NOT OK if (cond) { this.setState({}); // OK } } }); // definiteness and indirect call, in ES6 class class MyClass2 extends React.Component { constructor(props) { super(props); } componentWillUpdate() { this.definiteIndirectUpdate(); // NOT OK if (cond) { this.definiteIndirectUpdate(); // OK } this.indefiniteIndirectUpdate(); // OK return } definiteIndirectUpdate() { this.setState({}); } indefiniteIndirectUpdate() { if (cond) { this.setState({}); } } } // aliasing React.createClass({ render: function() { var app = this; app.setState({}); // NOT OK return } }); // indirect, in object literal React.createClass({ indirectUpdate: function() { this.setState({}) }, render: function() { this.indirectUpdate(); return } }); // eslint examples React.createClass({ componentDidUpdate: function() { this.setState({ // NOT OK name: this.props.name.toUpperCase() }); }, render: function() { return