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 ( ) } } export default withRedux(initStore)(Counter)