In my Next.JS app,I'm passing an array as a prop to OrderViewer component, but when I'm trying to read items of the passes array inside JSX, the following error is thrown.
Unhandled Rejection (TypeError): Cannot read property '0' of null
getOrderData = ID => {
if (ID !== null){
this.prt.style.display = "block";
console.log(ID) //This works well.but it doesn't work inside JSX.
console.log(`type = ${typeof(ID)}`)
}
}
render(){
return(
<div ref={ref => this.prt = ref} onLoad= {this.getOrderData(this.props.orderId)} style={{display: "none"}}>
<div id="OOP" className="row">
<div className={"row"}>
<div className="col-md-1">{this.props.orderId}</div>
<div className="col-md-10"></div>
<div className="col-md-1"></div>
</div>
<div></div>
</div>
</div>)
}
getOrderDatamethod but doesn't work inside jsx..this.props.orderIdit prints the whole array.but doesn't work with indices.