Imagine this action:
export const myAction = createAsyncThunk(...)
I dispatch the action in 2 different React components, both of which need this action to populate the state they depend on:
useEffect(() => {
dispatch(myAction())
}, [dispatch])
This, of course, causes the thunk to run its async code twice.
I want to do something similar to takeLeading
in Redux Saga with this thunk.
Is there a way I can get subsequent dispatches of myAction()
to be ignored while the first one is running?