2018-05-10 17:40:21 +00:00
|
|
|
/* eslint-disable */
|
2018-12-17 16:34:32 +00:00
|
|
|
import React, { Component } from 'react'
|
2018-05-10 17:40:21 +00:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
import { addCount } from '../store'
|
|
|
|
|
|
|
|
class AddCount extends Component {
|
|
|
|
add = () => {
|
|
|
|
this.props.addCount()
|
|
|
|
}
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
render() {
|
2018-05-10 17:40:21 +00:00
|
|
|
const { count } = this.props
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<style jsx>{`
|
|
|
|
div {
|
|
|
|
padding: 0 0 20px 0;
|
|
|
|
}
|
2018-12-17 16:34:32 +00:00
|
|
|
`}</style>
|
|
|
|
<h1>
|
|
|
|
AddCount: <span>{count}</span>
|
|
|
|
</h1>
|
2018-05-10 17:40:21 +00:00
|
|
|
<button onClick={this.add}>Add To Count</button>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
const mapStateToProps = state => ({ count: state.get('count') })
|
2018-05-10 17:40:21 +00:00
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
const mapDispatchToProps = dispatch => {
|
2018-05-10 17:40:21 +00:00
|
|
|
return {
|
|
|
|
addCount: bindActionCreators(addCount, dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(AddCount)
|