NA +91-8727899942 thecoderjob@gmail.com

CHAPTER - 58

Container - mapDispatchToProps - mapStateToProps

Its very important file to connect React or Redux

mapDispatchToProp - when send data from react to redux store

mapStateToProp - when send data from redux store to react

Here's is the Code !!

// HomeContainer.js
import Home from "../components/Home"
import {connect} from "react-redux"
import {addToCart} from "../service/actions/actions"

const mapStateToProps=state=>({
    // data:state.cardItems
})
const mapDispatchToProps=dispatch=>({
    addToCartHandler:data=>dispatch(addToCart(data))

})
export default connect(mapStateToProps,mapDispatchToProps)(Home)
// export default Home;

Chapter 57

Reducer and rootReducer in react js

Previous chapter

Chapter 59

Complete flow of redux

Next chapter

Get In Touch

NA

thecoderjob@gmail.com

+91-8727899942

Popular Links

© www.thecoderjob.com. All Rights Reserved.               Designed by HTML Codex