2019-03-14 17:40:00 +01:00
|
|
|
import React from 'react'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { startClock, serverRenderClock } from '../store'
|
|
|
|
import Examples from '../components/examples'
|
|
|
|
|
|
|
|
class Index extends React.Component {
|
2019-11-11 04:24:53 +01:00
|
|
|
static getInitialProps({ reduxStore, req }) {
|
2019-03-14 17:40:00 +01:00
|
|
|
const isServer = !!req
|
|
|
|
reduxStore.dispatch(serverRenderClock(isServer))
|
|
|
|
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
|
2019-11-11 04:24:53 +01:00
|
|
|
componentDidMount() {
|
2019-03-14 17:40:00 +01:00
|
|
|
const { dispatch } = this.props
|
|
|
|
this.timer = startClock(dispatch)
|
|
|
|
}
|
|
|
|
|
2019-11-11 04:24:53 +01:00
|
|
|
componentWillUnmount() {
|
2019-03-14 17:40:00 +01:00
|
|
|
clearInterval(this.timer)
|
|
|
|
}
|
|
|
|
|
2019-11-11 04:24:53 +01:00
|
|
|
render() {
|
2019-03-14 17:40:00 +01:00
|
|
|
return <Examples />
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect()(Index)
|