Skip to content

Instantly share code, notes, and snippets.

@joe-crick
Created March 26, 2018 06:25
Show Gist options
  • Save joe-crick/2476f7847194fde906d23c661240cf6a to your computer and use it in GitHub Desktop.
Save joe-crick/2476f7847194fde906d23c661240cf6a to your computer and use it in GitHub Desktop.
const Count = props => (
  <div>
    The count is {props.count}
    <button onClick={props.increment}>increment</button>
    <button onClick={props.incrementAsync}>incrementAsync</button>
  </div>
)

const mapState = state => ({
  count: state.count
})

const mapDispatch = ({ count: { increment, incrementAsync }}) => ({
  increment: () => increment(1),
  incrementAsync: () => incrementAsync(1)
})

const CountContainer = connect(mapState, mapDispatch)(Count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment