In React, a timer is set. Occasionally, ref cannot get it.

In

React, echarts is used through ref binding, and this part needs to re-render data using timer partition time. Occasionally, this ref cannot get

.

related codes

  componentWillReceiveProps(nextProps){
  ... // componentDidMount   
     this.interval = setInterval(() => {
             this.initchart()
     },time)
  }
initchart(xzqh){
  console.log(this.chart)   //   this.chart      
}
  render(){
  //refdom
 <div ref={(c) => this.policeRondEhart = c} style={{ width: "100%", height: "100%" }}></div>
}

is it because when the component state changes, the component render function will re-render so that the ref can"t get it?

Aug.31,2021
The this in

setInterval points to window. You need to call let vm = this, with vm outside setInterval to

Menu