While setting state , Even-though length of array is 9, Its displaying only first value. I'm not sure where its going wrong.
_GoTown = () => {
if (this.state.stTownRawData == '') {
alert(i18n.t('plsseltown'));
}
else {
this.setState({ stAtmList: [] });
var rartown = this.state.stTownRawData;
for (i = 0; i < rartown.length; i++) {
console.log(i);
this.setState({ stAtmList: this.state.stAtmList.concat({ key: i, town: i18n.t('town') + rartown[i].town, address: i18n.t('add') + rartown[i].addressLine1, lat: rartown[i].latitude, long: rartown[i].longitude, icon: require('../../resources/toolbar/atm.png') }) });
}
console.log(rartown);
}
}
Console.log(i) returns values from 0 to 8. I'm not sure why setState is populating stAtmList with only first value.