I have a react code as below which basically creates a treemap:
class ChartModal extends Component{
constructor(props){
super(props)
}
callApi(){
fetch(someurl)
.then((result) => {
return result.json();
}).then((jsonResult) => {
console.log(jsonResult);
})
}
render(){
return(
<Modal
onOk={() => this.props.toggleVisibility()}
onCancel={() => this.props.toggleVisibility()}
visible={this.props.isVisible}
okText={'ok'}
cancelText={'cancel'}
confirmLoading={false}
title="Intent distribution chart"
>
<h1>HOWDY</h1>
<TreeMap
data = {this.callApi()}//this is where i want the data returned by apicall
width={400}
valueUnit={'count'}
/>
</Modal>
)
}
}
Now I want the data returned by api call to be used inside the tree map
component, but the way I am doing it now doesn't seem to be working.
When I run this, the data in the tree map
comes out to be null though I expect a json
returned by api call
to be there.