再会!
有以下功能
import { connect, ConnectedProps } from 'react-redux';
import { TMethods, TState, TApp } from 'redux/types';
import { ComponentType } from 'react';
import action from 'redux/actions/app';
const mapState = (state: TState) => ({ ...state.app });
const mapDispatch = (dispatch: any) => ({ action: (method: TMethods, option: TApp) => dispatch(action(method, option)) });
const connector = connect(mapState, mapDispatch);
export default (component: ComponentType<any>) => connector(component);
export type TProps = ConnectedProps<typeof connector>;
我像这样使用上面的函数:
import connect from '...'
class ComponentName extends Component<PropsType, StateType> {***}
export default connect(ComponentName)
结果,在导入组件时,我看不到 PropsType,并且当将 props 传递给组件时,类型不可见。
问题:如何更改添加什么以及如何重写以便类型也通过连接传输?并尽可能摆脱任何。我将非常感谢您的帮助!
问题以这种方式解决: