ReactJS: setTimeout() not working?

前端 未结 10 2193

Having this code in mind:

var Component = React.createClass({

    getInitialState: function () {
        return {position: 0};    
    },

    componentDid         


        
10条回答
  •  长情又很酷
    2020-12-04 07:59

    Try to use ES6 syntax of set timeout. Normal javascript setTimeout() won't work in react js

    setTimeout(
          () => this.setState({ position: 100 }), 
          5000
        );
    

提交回复
热议问题