score:2

Accepted answer

pre or post increment, either way is the wrong way to increment a counter in react as both mutate state. state is also declared const, so it can't be updated anyway.

const count = 0;

++count; // error

console.log(count);

use a functional state update.

setcount(c => c + 1);

Related Query

More Query from same tag