forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathother.js
30 lines (27 loc) · 776 Bytes
/
other.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { startClock, addCount, serverRenderClock } from 'actions'
import Page from 'containers/page'
import withRedux from 'next-redux-wrapper'
import { compose, setDisplayName, pure, lifecycle, withProps } from 'recompose'
import initStore from '../store'
const Counter = compose(
setDisplayName('OtherPage'),
withProps({
title: 'Other page',
linkTo: '/'
}),
lifecycle({
componentDidMount () {
this.timer = this.props.startClock()
},
componentWillUnmount () {
clearInterval(this.timer)
}
}),
pure
)(Page)
Counter.getInitialProps = ({ store, isServer }) => {
store.dispatch(serverRenderClock(isServer))
store.dispatch(addCount())
return { isServer }
}
export default withRedux(initStore, null, { startClock })(Counter)