CounterView.js 808 B

12345678910111213141516171819202122
  1. import React from 'react';
  2. import {connect} from 'react-redux'
  3. import {actionInc, actionDec, actionPlus10} from '../actions'
  4. const CounterView = ({value, inc, dec}) =>
  5. <div>
  6. <button onClick={dec}>-</button>
  7. {value}
  8. <button onClick={inc}>+</button>
  9. </div>
  10. export default CounterView
  11. export const connector = connect(state => ({value: state.counter}) ,
  12. {inc: actionInc,
  13. dec: actionDec})
  14. export const ConnectedCounter = connector(CounterView)
  15. export const ConnectedBIGTABLO = connector(({value}) => <h1>{value}</h1>)
  16. export const BigButton = ({onPress}) => <button style={{fontSize: "5em"}} onClick={onPress}>+10</button>
  17. export const ConnectedBigButton = connect(null, {onPress: actionPlus10})(BigButton)