How can I wait for a dispatch to have updated the state? I didn't find anything in the useReducer API docs, neither do I find any indication in the TypeScript type defininition.
Here is what I have tried but did not work:
await new Promise<void>((resolve) => {
dispatch({ type: DO_SOMETHING, something });
resolve();
});
console.log(state.something); // still the old version