I am trying to make an interface that has the dispatch
function, but I am not using the Redux.
interface DispatchProps {
dispatch: (action: { type: string }) => void;
}
export function numberAddTwo({ dispatch }: DispatchProps) {
dispatch({ type: '@addTwoToNumber' })
}
But when I call the function here
const [state, dispatch] = useReducer(reducer, initialState);
<button className="btn" onClick={() => numberAddTwo(dispatch)}>+2</button>
The error appears at the dispatch parameter
Argument of type 'Dispatch<Action>' is not assignable to parameter of type 'DispatchProps'.
Property 'dispatch' is missing in type 'Dispatch<Action>' but required in type 'DispatchProps'.ts(2345)
I tried to find the Action
interface but I guess that is a Generic type.