rsnext/examples/with-redux-saga/components/counter.js
Tim Neutkens 9c4eefcdbf
Add prettier for examples directory (#5909)
* Add prettier for examples directory

* Fix files

* Fix linting

* Add prettier script in case it has to be ran again
2018-12-17 17:34:32 +01:00

40 lines
879 B
JavaScript

import React, { Component } from 'react'
import { connect } from 'react-redux'
import { increment, decrement, reset } from '../actions'
class Counter extends Component {
increment = () => {
this.props.dispatch(increment())
}
decrement = () => {
this.props.dispatch(decrement())
}
reset = () => {
this.props.dispatch(reset())
}
render () {
const { count } = this.props
return (
<div>
<style jsx>{`
div {
padding: 0 0 20px 0;
}
`}</style>
<h1>
Count: <span>{count}</span>
</h1>
<button onClick={this.increment}>+1</button>
<button onClick={this.decrement}>-1</button>
<button onClick={this.reset}>Reset</button>
</div>
)
}
}
const mapStateToProps = ({ count }) => ({ count })
export default connect(mapStateToProps)(Counter)