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