I'm developing a small react application that consist of a chart component and some other components. The chart component is a separate file/component/child component.When i click the button in the main container it calls a promise (using axio) and it returns some data as response. This response data is set as states and that state is passed to the chart component as props.But the chart doesn't load. This is because the chart has already being loaded, since the initial states where empty the chart is also empty. Is there any way of rendering the chart component only after the promise returns data?
this is my code
the button click event
ClickMe = () =>{
axios.get('http://xyzsdsd.com/abc')
.then((response)=>{
this.setState({
tags:response.data
});
console.log(this.state.tags);
}).catch((err)=>{
console.log(err);
});
}
the render function
render(){
return(
<div>
<otherComponents/>
<chart data={this.state.tags}/>
</div>
);
}