2016-12-22 05:10:54 +00:00
|
|
|
import React from 'react'
|
2018-12-17 16:34:32 +00:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { startClock, serverRenderClock } from '../store'
|
2018-05-07 13:03:54 +00:00
|
|
|
import Examples from '../components/examples'
|
2016-12-22 05:10:54 +00:00
|
|
|
|
2018-05-15 07:49:07 +00:00
|
|
|
class Index extends React.Component {
|
2018-05-07 13:03:54 +00:00
|
|
|
static getInitialProps ({ reduxStore, req }) {
|
|
|
|
const isServer = !!req
|
|
|
|
reduxStore.dispatch(serverRenderClock(isServer))
|
2017-04-30 20:44:24 +00:00
|
|
|
|
2018-05-07 13:03:54 +00:00
|
|
|
return {}
|
2016-12-22 05:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount () {
|
2018-12-17 16:34:32 +00:00
|
|
|
const { dispatch } = this.props
|
2018-05-07 13:03:54 +00:00
|
|
|
this.timer = startClock(dispatch)
|
2016-12-22 05:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
|
clearInterval(this.timer)
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2018-12-17 16:34:32 +00:00
|
|
|
return <Examples />
|
2016-12-22 05:10:54 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-18 04:10:27 +00:00
|
|
|
|
2018-05-15 07:49:07 +00:00
|
|
|
export default connect()(Index)
|