I have an array declared like this :
const [myArray,setMyArray] = useState([]);
I want to add a value in myArray and I found two methods for that:
Solution1: setMyArray([...myArray,value]);
Solution2: setMyArray(myArray => [...myArray,value]);
I read that these two solutions are not exactly the same and can give different results in some case. Can you please explain to me the exact difference between the two in a simple way?