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
Nguyen Hoang Phuc 530b561039 Add example for usage of redux + reselect + recompose (#2523)
* implemented example for using redux with reselect and recompose

* removed unused package

* fixed linting issue

* fixed linting issue
2017-07-11 20:17:00 +02:00

31 lines
781 B
JavaScript

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)