I'm trying to dispatch a function using Redux and Typescript in React, but I'm getting this error:
Argument of type '(dispatch: Dispatch) => void' is not assignable to parameter of type 'AnyAction'
Function 1:
const postProducts = (origin: string) => {
return (dispatch: Dispatch) => {
dispatch(initProducts(origin))
}
}
Function 2:
export const initProducts = (origin: string) => {
return (dispatch: Dispatch) => {
if (origin !== 'load') {
dispatch(setToastify(errorMsg))
}
}
}
Function 3:
export const setToastify = (toastifyDetails: string, open = true) => {
return {
type: ActionType.SET_TOASTIFY,
toastify: toastifyDetails,
open: open
}
}
P.S. I know nowadays I should be using Redux Toolkit, but this project is just for educational purposes.