Advertisement
joygabriel21

Connect Redux

Jan 21st, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import React from 'react'
  2. import { connect } from 'react-redux'
  3. import {incrementAction, decrementAction} from './actions'
  4.  
  5. const Counters = (props) => (
  6. <div>
  7. <h2>{props.counter}</h2>
  8. <button onClick={() => props.increment()}>+</button>
  9. <button onClick={() => props.decrement()}>-</button>
  10. </div>
  11. )
  12.  
  13. const mapStateToProps = (state) => (/*...*/)
  14. const mapDispatchToProps = (dispatch) => ({
  15. increment: () => dispatch(incrementAction()),
  16. decrement: () => dispatch(decrementAction())
  17. })
  18.  
  19. connect(mapStateToProps,mapDispatchToProps)(Counters)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement