9
ReactJS: setTimeout () không hoạt động?
Có mã này trong tâm trí: var Component = React.createClass({ getInitialState: function () { return {position: 0}; }, componentDidMount: function () { setTimeout(this.setState({position: 1}), 3000); }, render: function () { return ( <div className="component"> {this.state.position} </div> ); } }); ReactDOM.render( <Component />, document.getElementById('main') ); Không phải trạng thái sẽ thay …
100
javascript
reactjs