I have a problem when I'm trying to dispatch an async action in redux. I'm using redux-thunk to handle my async middlewares.
I have an async action function like this one:
function async() {
return dispatch => {
dispatch(req());
setTimeout(function() {
dispatch(rec());
}, 2000);
}
}
here is my createStore statement:
const store = createStore(
reducer,
applyMiddleware(thunk)
);
When Im trying to do this: store.dispatch(async())
I'm getting this kind of error:
error TS2345: Argument of type '(dispach: any) => void' is not assignable to parameter of type 'Action'
The code itself works when I'm just using javascript.