scrimba
React Bootcamp Course
Redux in React - mapDispatchToProps
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Redux in React - mapDispatchToProps
AboutCommentsNotes
Redux in React - mapDispatchToProps
Expand for more info
App.js
run
preview
console
import React from "react"
import {connect} from "react-redux"

function App(props) {
return (
<div>
<h1>{props.count}</h1>
<button>-</button>
<button>+</button>
</div>
)
}

// Write the mapStateToProps function from scratch
// Takes the global state from Redux as a parameter
// returns an object where the keys are the name of the prop your component wants,
// and the values are the actual parts of the global state your component wants
function mapStateToProps(state) {
return {
count: state
}
}


export default connect(mapStateToProps, {})(App)
Console
/index.html
-6:34