React Push Object Into Array, Always Pushed Last Array
i'm new on React Js things. already tried push object into array. I already got the result using axios, but i can't push it to array.the result always return last array, F.ex : [0
Solution 1:
You are adding tempObj to temp array on each iteration and changing value of tempObj as well.
So by reference you are updating value of each item because all items of array point to same object.
Solution 2:
Solution 3:
Try unshift()
instead push()
to adds item to front of array
Post a Comment for "React Push Object Into Array, Always Pushed Last Array"