score:0

i am still not sure why i can't update an array state in a loop but i have found a turn around for this. rather than putting

setmessagestate() in usestate, i have put the for loop in the function settablecontent() itself.

const settablecontent = (row: number, err: any) => {
 const values = []
 for(let i=0; i < 6; i++) {
   values.push(getstatus(i, err));
}
setmessagetype(values);
 }

and now its working


Related Query

More Query from same tag