It is the action performed by the user. It can be a value of any type.
By convention, an action is usually an object with a type property identifying it and, optionally, other properties with additional information.
Actions can take any shape. They should include the minimal information that the reducer needs to compute the next state.
The dispatch function only updates the state variable for the next render. If you read the state variable after calling the dispatch function, you will still get the old value that was on the screen before your call.
If the new value you provide is identical to the current state, as determined by an Object.is comparison, React will skip re-rendering the component and its children. This is an optimisation. React may still need to call your component before ignoring the result, but it shouldn’t affect your code.
React batches state updates. It updates the screen after all the event handlers have run and have called their set functions. This prevents multiple re-renders during a single event. In the rare case that you need to force React to update the screen earlier, for example, to access the DOM, you can use flushSync.