mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
28 lines
620 B
JavaScript
28 lines
620 B
JavaScript
import React from 'react'
|
|
import { initStore, startClock } from '../store'
|
|
import withRedux from 'next-redux-wrapper'
|
|
import Page from '../components/Page'
|
|
|
|
class Counter extends React.Component {
|
|
static getInitialProps ({ store, isServer }) {
|
|
store.dispatch({ type: 'TICK', light: !isServer, ts: Date.now() })
|
|
return { isServer }
|
|
}
|
|
|
|
componentDidMount () {
|
|
this.timer = this.props.dispatch(startClock())
|
|
}
|
|
|
|
componentWillUnmount () {
|
|
clearInterval(this.timer)
|
|
}
|
|
|
|
render () {
|
|
return (
|
|
<Page title='Other Page' linkTo='/' />
|
|
)
|
|
}
|
|
}
|
|
|
|
export default withRedux(initStore)(Counter)
|