Redux Practice Example 3

Provider to index.js

index.js

import { Provider } from 'react-redux';
import { store } from './redux/store.js';


    <Provider store={store}>
        <App />
    </Provider>,

Connect to components

hoge.js


*use the state or dispatch as props of the component

const mapStateToProps = (state) => ({
   hoge: state.hoge.blah, 
})

const mapDispatchToProps = (dispatch) => ({
   hoge: () => dispatch(hoge()),
})

const export connect(mapStateToProps)(Hoge);
const export connect(null, mapDispatchToProps)(Hoge);
const export connect(mapStateToProps, mapDispatchToProps)(Hoge);