有什么方法可以从redux-mock-store创建的商店中正确调度Thunk吗?现在我被迫使用任何类型断言
store.dispatch<any>(getCommissions());
Run Code Online (Sandbox Code Playgroud)
如dispatch预期的那样提供简单的操作
[ts]
Argument of type '(dispatch: ThunkDispatch<IRootState, undefined,
AnyAction>, getState: () => IRootState) => void' is not assignable to parameter of type 'AnyAction'.
Property 'type' is missing in type '(dispatch: ThunkDispatch<IRootState, undefined, AnyAction>, getState: () => IRootState) => void'.
Run Code Online (Sandbox Code Playgroud)
的代码片段 getCommisions()
export function getCommissions() {
return (dispatch: ThunkDispatch<IRootState, undefined, AnyAction>, getState: () => IRootState) => { ... }
Run Code Online (Sandbox Code Playgroud) 我无法static在连接到 Redux 的类组件中使用方法。打字稿报告
Argument of type 'typeof SAI' is not assignable to parameter of type 'ComponentType<IStateProps & IDispatchProps>'.
Type 'typeof SAI' is not assignable to type 'StatelessComponent<IStateProps & IDispatchProps>'.
Type 'typeof SAI' provides no match for the signature '(props: IStateProps & IDispatchProps & { children?: ReactNode; }, context?: any): ReactElement<any> | null'.
Run Code Online (Sandbox Code Playgroud)
容器:
export interface IStateProps {
saiList: ISaiList
}
const mapStateToProps = (state: IRootState) => ({
saiList: SaiListSelector(state)
});
export interface IDispatchProps {
getSai: () => Dispatch<AnyAction>; …Run Code Online (Sandbox Code Playgroud)