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?