This is how you need to do it:
render(){
const {data} = this.state;
return(
<div>
{
data.length ?
data.map(
info => {
return(
<div>
<h2 key={info.id}>{info.id, info.name, info.stock}</h2><br/>
<script scr={console.log(info)}/>
</div>)
}):null
}
this is data from api
</div>
);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…