1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-redux/pages/index.js
2017-02-18 20:12:19 +01:00

28 lines
625 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='Index Page' linkTo='/other' />
)
}
}
export default withRedux(initStore)(Counter)