I've ran into a question I'd like clarification on.
The conventional way of updating an array using use state is like this: setArray((oldArray) => [...oldArray, newElement]);
But now I see that this also works: setArray([...oldArray, newElement]);
What is the difference between these two ways and why is one chosen over the other?