redux 如何将mapStateToProps替换为挂钩useSelector?

vq8itlhq  于 2022-11-12  发布在  其他
关注(0)|答案(1)|浏览(110)

如何替换这个mapStateToProps代码来挂钩useSelector?我以前从未使用过redux,并且很难理解它。

interface BasicProductMarksListOwnProps {
   productMarks: MarkResult[];
}
interface BasicProductMarksListStore {
   productMarksState: AdditionalFilterState;
}
interface BasicProductMarksListActions {
   onProductMarkChange: (productMarkGroupId: GenericId, isActive: boolean) => 
       () => void;
}

export type BasicProductMarksListProps = BasicProductMarksListOwnProps 
    & BasicProductMarksListStore & BasicProductMarksListActions;

const mapStateToProps: MapStateToProps<BasicProductMarksListStore, 
    BasicProductMarksListOwnProps, ApplicationState> = (state) => ({
   productMarksState: productMarksGroupStateSelector(state),
});
ibps3vxo

ibps3vxo1#

从您提供的代码中,我假设以下代码可以工作。
const productMarks = useSelector(state => productMarksGroupStateSelector(state)) .
请确保在功能组件内执行上述代码。

相关问题