2017-08-27 20:13:35 +00:00
|
|
|
import React from 'react'
|
2018-12-17 16:34:32 +00:00
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { namespaceConfig } from 'fast-redux'
|
2017-08-27 20:13:35 +00:00
|
|
|
import Link from 'next/link'
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
const DEFAULT_STATE = { version: 1 }
|
2017-08-27 20:13:35 +00:00
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
const { actionCreator, getState: getAboutState } = namespaceConfig(
|
|
|
|
'about',
|
|
|
|
DEFAULT_STATE
|
|
|
|
)
|
2017-08-27 20:13:35 +00:00
|
|
|
|
2018-09-22 19:41:07 +00:00
|
|
|
const bumpVersion = actionCreator('bumpVersion', function (state, increment) {
|
2018-12-17 16:34:32 +00:00
|
|
|
return { ...state, version: state.version + increment }
|
2017-08-27 20:13:35 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
const About = ({ version, bumpVersion }) => (
|
|
|
|
<div>
|
|
|
|
<h1>About us</h1>
|
|
|
|
<h3>Current version: {version}</h3>
|
2018-12-17 16:34:32 +00:00
|
|
|
<p>
|
|
|
|
<button onClick={e => bumpVersion(1)}>Bump version!</button>
|
|
|
|
</p>
|
|
|
|
<Link href='/'>
|
|
|
|
<a>Homepage</a>
|
|
|
|
</Link>
|
2017-08-27 20:13:35 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
return getAboutState(state, 'version')
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return bindActionCreators({ bumpVersion }, dispatch)
|
|
|
|
}
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps
|
|
|
|
)(About)
|