react添加和删除定时器的地方

添加定时器
  componentDidMount() {
    this.timerID = setInterval(
      () => this.tick(),
      1000
    );
  }

 删除定时器

  componentWillUnmount() {
    clearInterval(this.timerID);
  }

  

 
原文地址:https://www.cnblogs.com/javenlee/p/7986820.html