I have a Thunk Action that looks like:
export const doTestCall = (teamId:string): ThunkAction<()=>void, RootState, null, MoodAction> => {
return dispatch => {
const unsubscribe = db.doc("id").onSnapshot(doc =>{
//whatever
});
return unsubscribe;
}
}
In my react component I have the following hook:
useEffect(() => {
const unsubscribe = dispatch(doSomething()) as ()=>void;
return () => unsubscribe();
}, []);
This code actually works. Question I have, how can I remove forcing the
as ()=>void
If I do, code complains in the "return line" with:
const unsubscribe: (dispatch: ThunkDispatch<RootState, null, MoodAction>, getState: () => RootState, extraArgument: null) => void
Expected 3 arguments, but got 0.ts(2554)
index.d.ts(9, 3): An argument for 'dispatch' was not provided.
Thanks,