Skip to content

Instantly share code, notes, and snippets.

@samcorcos
Last active August 14, 2016 05:34
Show Gist options
  • Save samcorcos/2e1e06e5e4e978ad783d833919ea3d9f to your computer and use it in GitHub Desktop.
Save samcorcos/2e1e06e5e4e978ad783d833919ea3d9f to your computer and use it in GitHub Desktop.
import React from 'react'
import { connect } from 'react-redux'
import Actions from './Actions.js'
class App extends React.Component {
constructor(props) {
super(props)
this.addOne = this.addOne.bind(this)
}
addOne() {
this.props.dispatch(Actions.addOne())
}
render() {
return (
<div>
<button
onClick={ this.addOne }>
Increment
</button>
{ this.props.counter }
</div>
)
}
}
const mapStateToProps = store => {
return {
counter: store.counter
}
}
export default connect(mapStateToProps)(App)
@imvetri
Copy link

imvetri commented Aug 14, 2016

I was brought here from a react article hosted at medium. Thanks for sharing. 👍

I had one question for clarification.

line #28 - 32, can that be simplified further?

Please let me know your thoughts on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment