Value passing problem of react component

wrote a component of the broadcast graph, but never got the correct value when passing the value.
has a total of four pictures, and the img element has been rendered, but the imgNum=0,imgWidth=NAN,
picture data is obtained from the server through ajax. The
code is as follows:

<Banner imgNum={this.state.imgs.length} imgWidth={this.state.imgWidth}>
 {this.state.imgs.map((val,index) => (
    <img
        key={index}
        src={`${Tool.IP}/ydcsPhone/goodsInfo/downloadGoodsPicture?goodsInfoId=${this.gID}&goodsPictureName=${val}&session=${Tool.SESSION}`}
         alt=""
         style={{ float:"left",width:this.state.imgWidth,height:this.state.imgHeight}}
     />
 ))}
</Banner>
Feb.19,2022

should be pointing to the wrong this. The problem is solved by defining const self = this;
in render and then using style = {width: self.state.imgWidht}}


in img, because the data is obtained asynchronously through ajax, so it is passed to the parent component before it is obtained.

can be solved by making if judgment before loading the component.
Menu