我有一个问题,我不知道如何解决。我正在尝试将Redux与React-Typescript一起使用。当我想访问商店的调度功能时,Typescript会引发错误。在下面,您可以看到错误和我的代码。当我将商店的类型替换为任何类型时,该代码有效。您对如何解决此问题有建议吗?
Argument of type 'ThunkAction<Promise<any>, IThemeState, null, IToggleTheme>' is not assignable to parameter of type 'AnyAction'.
Property 'type' is missing in type 'ThunkAction<Promise<any>, IThemeState, null, IToggleTheme>' but required in type 'AnyAction'.ts(2345)
index.d.ts(19, 3): 'type' is declared here.
(property) payload: any
const addName: React.SFC<{}> = () => {
return (
<ReactReduxContext.Consumer>
{({ store }: ReactReduxContextValue) => (
<button
onClick={() => {
store.dispatch(
toggleTheme({
payload: store.getState().themeState.darkMode,
type: EThemeActionTypes.TOGGLE
})
)
}}
/>
)}
</ReactReduxContext.Consumer>
)
}