componentDidMount(){
//got data from AJAX call
this.setState({data:data});
}
render(){
this.state.data ? <div>{ this.state.data.map((item,index) =>
<span key={index}> {item.value} </span>
)} </div>
: <div> Loading ... </div>
}
You've to write a ternary operator (an IF-else will also do, but I prefer ternary). There will be 2 states , the initial state when there's no data and the state where you've the data from the AJAX call. Whenever you set the state using setState function react will automatically call the render method and change your view according to the data. Hope this helped.