prevstate in `this.setState` -- a copy or a reference?

Viewed 2043

I've been trying to figure this out for a while and haven't come across the correct answer.

In the following code:

this.setState(prevState => counter: prevState.counter + 1);

is prevState a reference to the current state? Or is it a copy of it? Is it fine to mutate or should mutating it be avoided?

1 Answers
Related