Search code examples
reactjsredux

How to replace mapStateToProps with useSelector in Redux?


I'm new to Redux and need help converting this mapStateToProps function to the useSelector hook:

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

How do I replace this with useSelector?

Thanks!


Solution

  • From the code you provided I assume the following would work.

    const productMarks = useSelector(state => productMarksGroupStateSelector(state)).

    Make sure to execute the code above inside a functional component.