I have a React
action like this:
export const sigIn = () =>
async (dispatch: any) => {
dispatch({
type: SIGN_IN_REQUEST
});
};
I'm getting a:
ESLint: Argument 'dispatch' should be typed with a non-any type.(@typescript-eslint/explicit-module-boundary-types)
as a warning on the async
. Why?
Edit: for both answers, I put the Dispatch
type from redux
but I still have the warning:
You're getting the error because you used any
, and your lint rules forbid that. The fix is to use the correct type for dispatch, which can be imported from redux:
import { Dispatch } from 'redux';
export const sigIn = () =>
async (dispatch: Dispatch) => {
dispatch({
type: SIGN_IN_REQUEST
})
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With