2020-01-09 16:31:49 +01:00
|
|
|
import React from 'react'
|
2018-03-06 13:34:28 +01:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { bindActionCreators } from 'redux'
|
2020-01-09 16:31:49 +01:00
|
|
|
import { addCount } from '../store/count/action'
|
2018-03-06 13:34:28 +01:00
|
|
|
|
2020-01-09 16:31:49 +01:00
|
|
|
const AddCount = ({ count, addCount }) => {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<style jsx>{`
|
|
|
|
div {
|
|
|
|
padding: 0 0 20px 0;
|
|
|
|
}
|
|
|
|
`}</style>
|
|
|
|
<h1>
|
|
|
|
AddCount: <span>{count}</span>
|
|
|
|
</h1>
|
|
|
|
<button onClick={addCount}>Add To Count</button>
|
|
|
|
</div>
|
|
|
|
)
|
2018-03-06 13:34:28 +01:00
|
|
|
}
|
|
|
|
|
2020-01-09 16:31:49 +01:00
|
|
|
const mapStateToProps = state => ({
|
|
|
|
count: state.count.count,
|
|
|
|
})
|
2018-03-06 13:34:28 +01:00
|
|
|
|
2018-12-17 17:34:32 +01:00
|
|
|
const mapDispatchToProps = dispatch => {
|
2018-03-06 13:34:28 +01:00
|
|
|
return {
|
2019-05-29 01:06:13 +02:00
|
|
|
addCount: bindActionCreators(addCount, dispatch),
|
2018-03-06 13:34:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-11 04:24:53 +01:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AddCount)
|