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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eadb4c-2177.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eadb4c-2177.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?