当你使用注射道具
mapStateToProps,并
dispatchProps在
connect您必须减去从这些道具
baseProps使用泛型类型
Diff的辅助型。此外,如果要在
Hoc组件中使用这些注入的Props,则必须将它们作为Componenttype参数传递。例如
React.Component<InjectedProps>。
这是错误的原因。
因此,在您的示例中,道具是:
type InjectedProps = TStateProps & TDispatchProps;type HocProps = Diff<baseProps, InjectedProps>;class Hoc extends React.Component<InjectedProps> { ... }const ConnectedHoc = connect< TStateProps, TDispatchProps, HocProps, RootState >( mapStateToProps, dispatchProps )(Hoc);另外,请检查react-redux-typescript-guide中的相同讨论



