Answers for "react-redux provider"

1

react-redux provider

/* Using React-Redux Provider */
import React from 'react';
import { Provider, connect } from 'react-redux';

const mapStateToProps = (state) => {
  return { myProp: state.myProp }
};
const mapDispatchToProps = (dispatch) => {
  return { propName: (param) => { dispatch(actionCreator(param)) } }
};

const Container = connect(mapStateToProps, mapDispatchToProps)(App);

export default class AppWrapper extends React.Component {
    render() {
        return (
            <Provider store={store}>
                <Container />
            </Provider>
        );
    }
}
Posted by: Guest on March-07-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language