In your constructor bind that function to your current class ,
as below :
constructor( props ){
super( props );
this.myLoop = this.myLoop.bind(this);
}
function myLoop() {
// self = this;
let xhr1 = new XMLHttpRequest();
xhr1.open('GET', data.data[0].sideList[i].sideSvg);
xhr1.onload = () => {
document.getElementById("configurator_side_" + i)
.appendChild(xhr1.responseXML.documentElement);
i++;
this.props.dispatch(storeActions.setSideThumbSvg());
if (i < data.data[0].sideList.length) {
myLoop();
}
};
xhr1.send();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…