【bug记录】 Argument of type ‘AsyncThunkAction<void, string, {}>‘ is not assignable to parameter of type
const dispatch = useDispatch(); // 这里const dispatch: Dispatch<AnyAction>useEffect(() => {dispatch(getProductDetail(touristRouteId));}, [])
getProductDetail的类型是 AsyncThunk<void, string, {}>,但是const dispatch: Dispatch<AnyAction>。
export const getProductDetail=createAsyncThunk("productDetail/getProductDetail",async (touristRouteId:string, thunkAPI) => {const fetchData = async () => {thunkAPI.dispatch(productDetailSlice.actions.fetchStart());try {const { data } = await axios.get(`http://123.56.149.216:8080/api/touristRoutes/${touristRouteId}`);thunkAPI.dispatch(productDetailSlice.actions.fetchSuccess(data));} catch (error) {thunkAPI.dispatch(productDetailSlice.actions.fetchFail(error.message));}};fetchData();}
)
两种解决办法:
一是定义getProductDetail是any类型
export const getProductDetail:any=createAsyncThunk("productDetail/getProductDetail",async (touristRouteId:string, thunkAPI) => {const fetchData = async () => {thunkAPI.dispatch(productDetailSlice.actions.fetchStart());try {const { data } = await axios.get(`http://123.56.149.216:8080/api/touristRoutes/${touristRouteId}`);thunkAPI.dispatch(productDetailSlice.actions.fetchSuccess(data));} catch (error) {thunkAPI.dispatch(productDetailSlice.actions.fetchFail(error.message));}};fetchData();}
)
二是用getDefaultMiddleware().concat而不是[...getDefaultMiddleware(),...]
const store = configureStore ({reducer:rootReducer,// 不要用展开运算符这种写法 middleware: (getDefaultMiddleware) => [...getDefaultMiddleware(), actionLog, changeLanguage],middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(actionLog,changeLanguage), devTools:true
});
【bug记录】 Argument of type ‘AsyncThunkAction<void, string, {}>‘ is not assignable to parameter of type相关推荐
- TypeScript语法错误:Argument of type ‘string‘ is not assignable to parameter of type ‘Element‘. 解决方法
问题描述 DOM插入元素节点报错. TypeScript语法错误: TS2345: Argument of type 'string' is not assignable to parameter o ...
- Argument of type ‘string‘ is not assignable to parameter of type ‘never‘.
在react中遇到了一个这样的问题Argument of type 'string' is not assignable to parameter of type 'never'. 更改之前: 更改之 ...
- Argument of type ‘‘ is not assignable to parameter of type ‘never‘.
最近在写ts代码,记录下开发中遇到的代码规范问题 Argument of type 'any' is not assignable to parameter of type 'never'. // 问 ...
- typeScript踩坑记录 T2345 Argument of type is not assignable to parameter of type never
最近在对接谷歌的localhomeSDK,详情看这里https://aijishu.com/a/1060000000011433,[后续对接完成会写一篇踩坑的血泪史==]应用他们的sdk需要的语言可用 ...
- 当使用pinia遇见Argument of type ‘any‘ is not assignable to parameter of type ‘never‘解决方法
state return的数据改为. goodsArray:[] as any[] 通过 as 进行类型断言欺骗ts类型约束
- vue3 router.push 传参路由跳转错误提示 Argument type {xxx} is not assignable to parameter type RouteLocationRaw
文章目录 问题描述 解决方法 问题描述 传参时,router.push中布尔值变量会给出一个错误提示 setup(){const router = useRouter();/** 查看已办任务的流程记 ...
- Failed to convert value of type 'java.lang.String' to required type 'java.util.Date
异常原因:Controller层获取JSP页面请求参数是String类型,而在Controller层接收时使用Date类型,属于方法参数类型不匹配异常 警告: Failed to bind reque ...
- 解决 No converter found capable of converting from type [java.lang.String] to type ... 的问题
目录 问题 分析问题 解决问题 问题 今天在项目启动类SuperJsonManagerApplication中,加上这行代码@MapperScan("com.**.mapper") ...
- springboot启动报错Parameter 0 of method a in com.* required a bean of type 'java.lang.String' that could
springboot服务启动报错,报错信息如下 *************************** APPLICATION FAILED TO START ******************** ...
最新文章
- 什么是数据结构,为什么我们需要数据结构?
- xp装linux一键安装教程图解,XP下硬盘安装CentOS 6.0图解教程
- python后端将svc文件数据读入数据库具体实现
- javascript设置和获取cookie的方法
- 使用Roslyn将代码编译成单独的网络模块并将它们组装成动态库
- 大数据之-Hadoop之HDFS_HDFS的优缺点---大数据之hadoop工作笔记0049
- 自定义iOS UIPickerView
- LINUX编译Android FFmpeg:fatal error: errno.h: No such file or directory
- SpringBoot生成条形码
- 如何成为一名优秀的测试/开发程序员?专注谋定而后动......
- 台式计算机锁屏快捷键,台式机锁屏快捷键是什么
- 复合高斯求积matlab代码,谁有复何求积公式和高斯求积公式在matlab中实现的代码...
- 戴尔3080计算机重装系统步骤,戴尔OptiPlex 3080MT台式机重装系统BIOS设置教程
- 改变linux字体的大小,如何更改字体并调整其大小?
- Allegro PCB Design GXL (legacy) - 铺网格铜
- 具体应如何办理股票开户?
- (原创)梅子与锤子的一生(光阴故事)
- python用循环结构求平均值_有python的输出问题;循环总数和平均值
- springmvc(尚硅谷版)
- 哈希冲突和一致性哈希
热门文章
- Zynq实现分布式Fir滤波器
- 集群服务器上的jupyter配置
- stm32f105vct6例程_STM32F105VCT6_USB_TEST
- STM32F105替换为AT32F403A注意事项
- 2017开发语言排行(本人是搞C#+javascript的)
- 亚马逊echo中国使用_我需要Amazon Echo才能使用Alexa吗?
- 几种颜色单位设置(颜色设置)
- 如何更改Code::Blocks背景颜色(懒人版)
- Oracle 查询临时表空间
- 翻译《Pro SQL Server Internals,2nd edition》的CHAPTER 3 Statistics的Introduction to SQL Server Statistics等