rsnext/examples/with-redux/pages/other.js

28 lines
620 B
JavaScript
Raw Normal View History

import React from 'react'
2017-02-18 20:12:19 +01:00
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='/' />
)
}
}
2017-02-18 20:12:19 +01:00
export default withRedux(initStore)(Counter)