I received an array of objects from nodejs server, a = [{...},{...},{...}....]
. But when I tried to assign the entire array to a react state using setArray(a)
, only the first element was assigned to the state.
To find out why, I console.log(a)
the array to see what's in it, but what's showing on the console really confuses me:
I suppose the (6)
here means length is 6 but if I expand it only one element is visible.
but if I
for(const x of a ){
console.log(x)
}
all six objects are printed. Did I do something wrong?