provider from react-redux code example

Example 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>
        );
    }
}

Example 2: redux import connect

import { connect } from 'react-redux'

Example 3: can you wrap redux provider within react.strictmode

// React.StrictMode should wrap the whole application including the provider too. So Change your code like bellow:  
  <React.StrictMode>
    <Provider store={store}>
      <App />
    </Provider>
  </React.StrictMode>,
  document.getElementById('root')

Tags:

Html Example