- #1
shivajikobardan
- 674
- 54
- TL;DR Summary
- spread operator in react js.
Code for this is here:
https://codesandbox.io/s/floral-frog-7zfon3
I got the general idea of program flow in this case.
First user clicks a button, then function gets called, that function in turn updates the state from initial [] state to [{id:1,value:0.12232}]. Now the array map accesses the value and displays in a list.
But I don't understand why did we use spread operator there. If I remove spread operator, I can see the difference, but I'm not understanding what spread operator is doing here enough to apply the concept of spread operator in other projects.
I have learnt about spread operator from MDN docs already.
https://codesandbox.io/s/floral-frog-7zfon3
I got the general idea of program flow in this case.
First user clicks a button, then function gets called, that function in turn updates the state from initial [] state to [{id:1,value:0.12232}]. Now the array map accesses the value and displays in a list.
But I don't understand why did we use spread operator there. If I remove spread operator, I can see the difference, but I'm not understanding what spread operator is doing here enough to apply the concept of spread operator in other projects.
I have learnt about spread operator from MDN docs already.