setInterval function without arrow function

后端 未结 7 792
盖世英雄少女心
盖世英雄少女心 2021-01-02 07:20

I am learning about react components following the documentation https://facebook.github.io/react/docs/state-and-lifecycle.html

Why do we need to use arrow function

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-02 08:03

    If you are not using arrow function then your code should look something like this:

    this.timerID = setInterval(function(){ this.tick() }, 1000);
    

提交回复
热议问题