ReactJS
Why we need to pass a function to React setState() method?
The reason for this is that setState() is an asynchronous operation. React batches state changes, so the state may not change after setState() is called.
The reason for this is that setState() is an asynchronous operation. React batches state changes, so the state may not change after setState() is called.