2017-01-08 15:04:35 +00:00
|
|
|
import React from 'react'
|
2017-04-30 20:44:24 +00:00
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
import { initStore, startClock, addCount, serverRenderClock } from '../store'
|
2017-02-18 19:12:19 +00:00
|
|
|
import withRedux from 'next-redux-wrapper'
|
2017-01-08 15:04:35 +00:00
|
|
|
import Page from '../components/Page'
|
|
|
|
|
2017-02-18 04:10:27 +00:00
|
|
|
class Counter extends React.Component {
|
|
|
|
static getInitialProps ({ store, isServer }) {
|
2017-04-30 20:44:24 +00:00
|
|
|
store.dispatch(serverRenderClock(isServer))
|
|
|
|
store.dispatch(addCount())
|
2017-02-18 04:10:27 +00:00
|
|
|
return { isServer }
|
2017-01-08 15:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
2017-04-30 20:44:24 +00:00
|
|
|
this.timer = this.props.startClock()
|
2017-01-08 15:04:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
2017-02-18 17:11:54 +00:00
|
|
|
<Page title='Other Page' linkTo='/' />
|
2017-01-08 15:04:35 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-02-18 04:10:27 +00:00
|
|
|
|
2017-04-30 20:44:24 +00:00
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
return {
|
|
|
|
addCount: bindActionCreators(addCount, dispatch),
|
|
|
|
startClock: bindActionCreators(startClock, dispatch)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withRedux(initStore, null, mapDispatchToProps)(Counter)
|