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-reselect-recompose/pages/index.js

31 lines
781 B
JavaScript
Raw Normal View History

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('IndexPage'),
withProps({
title: 'Index page',
linkTo: '/other'
}),
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)