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/other.js
胡子大哈 ba54c6ac3d Use the original idea of provider wrapper for redux example (#1201)
Use the original idea of provider wrapper from #1193 and remove
unnecessary `initStore` in every page.
2017-02-18 14:03:02 -03:00

28 lines
685 B
JavaScript

import React from 'react'
import { nextConnect, reducer, startClock, setPageTitle } from '../store'
import Page from '../components/Page'
class Counter extends React.Component {
static getInitialProps ({ store, isServer }) {
store.dispatch({ type: 'TICK', light: !isServer, ts: Date.now() })
store.dispatch({ type: 'SET_PAGE_TITLE', title: 'Other Page' })
return { isServer }
}
componentDidMount () {
this.timer = this.props.dispatch(startClock())
}
componentWillUnmount () {
clearInterval(this.timer)
}
render () {
return (
<Page title={this.props.title} linkTo='/' />
)
}
}
export default nextConnect((state) => state)(Counter)