gpt4 book ai didi

reactjs - react Action ,ESLint : Argument 'dispatch' should be typed with a non-any type

转载 作者:行者123 更新时间:2023-12-04 12:36:14 24 4
gpt4 key购买 nike

我有一个 React像这样的 Action :

export const sigIn = () =>
async (dispatch: any) => {
dispatch({
type: SIGN_IN_REQUEST
});
};
我得到一个:
ESLint: Argument 'dispatch' should be typed with a non-any type.(@typescript-eslint/explicit-module-boundary-types)
作为 async 上的警告.为什么?
编辑:对于这两个答案,我都输入了 Dispatch输入来自 redux但我仍然有警告:
enter image description here
enter image description here

最佳答案

您收到错误是因为您使用了 any ,而您的 lint 规则禁止这样做。解决方法是使用正确的调度类型,可以从 redux 导入:

import { Dispatch } from 'redux';

export const sigIn = () =>
async (dispatch: Dispatch) => {
dispatch({
type: SIGN_IN_REQUEST
})
};

关于reactjs - react Action ,ESLint : Argument 'dispatch' should be typed with a non-any type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64574836/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com