2016-12-22 05:10:54 +00:00
|
|
|
import React from 'react'
|
2017-02-18 19:12:19 +00:00
|
|
|
import { initStore, startClock } from '../store'
|
|
|
|
import withRedux from 'next-redux-wrapper'
|
2017-01-08 15:04:35 +00:00
|
|
|
import Page from '../components/Page'
|
2016-12-22 05:10:54 +00:00
|
|
|
|
2017-02-18 04:10:27 +00:00
|
|
|
class Counter extends React.Component {
|
|
|
|
static getInitialProps ({ store, isServer }) {
|
2017-01-08 15:04:35 +00:00
|
|
|
store.dispatch({ type: 'TICK', light: !isServer, ts: Date.now() })
|
2017-02-18 04:10:27 +00:00
|
|
|
return { isServer }
|
2016-12-22 05:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
2017-02-18 04:10:27 +00:00
|
|
|
this.timer = this.props.dispatch(startClock())
|
2016-12-22 05:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
|
clearInterval(this.timer)
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
2017-02-18 17:11:54 +00:00
|
|
|
<Page title='Index Page' linkTo='/other' />
|
2016-12-22 05:10:54 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
2017-02-18 04:10:27 +00:00
|
|
|
|
2017-02-18 19:12:19 +00:00
|
|
|
export default withRedux(initStore)(Counter)
|