gpt4 book ai didi

reactjs - 预期为 0 个参数,但在实现 redux 时得到 1.ts(2554) 使用 typesafe-actions 进行操作

转载 作者:行者123 更新时间:2023-12-04 10:01:34 25 4
gpt4 key购买 nike

我正在使用 typescript 。
我正在使用类型安全操作进行 redux 操作

我的代码如下:

行动

export const setCount = createAction(
types.SET_COUNT,
resolve => (dataCount: CountModel) => resolve({ dataCount }),
);

预期 0 个参数,但得到 1.ts(2554)

我该如何解决?

索引.tsx
  const setCount = (values: CountModel) => {
dispatch(action.setCount(values))
}


setCount 函数通知语法错误:

最佳答案

在此处找到解决方案 https://redux-toolkit.js.org/usage/usage-with-typescript
只需在方法后添加类型:

export const setCount = createAction<number>(...);

关于reactjs - 预期为 0 个参数,但在实现 redux 时得到 1.ts(2554) 使用 typesafe-actions 进行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61801635/

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