2018-06-19 19:50:37 +00:00
|
|
|
import React from 'react'
|
2018-12-05 10:32:45 +00:00
|
|
|
import Link from 'next/link'
|
2018-06-19 19:50:37 +00:00
|
|
|
import { Subscribe } from 'unstated'
|
|
|
|
import { ClockContainer, CounterContainer } from '../containers'
|
|
|
|
import { Clock, Counter } from '../components'
|
|
|
|
|
|
|
|
class Index extends React.Component {
|
|
|
|
componentWillUnmount () {
|
|
|
|
clearInterval(this.timer)
|
|
|
|
}
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<Subscribe to={[ClockContainer, CounterContainer]}>
|
2018-12-17 16:34:32 +00:00
|
|
|
{(clock, counter) => {
|
|
|
|
this.timer = clock.interval
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Link href='/about'>
|
|
|
|
<button>go to About</button>
|
|
|
|
</Link>
|
2018-06-19 19:50:37 +00:00
|
|
|
<div>
|
2018-12-17 16:34:32 +00:00
|
|
|
<Clock clock={clock} />
|
|
|
|
<Counter counter={counter} />
|
2018-06-19 19:50:37 +00:00
|
|
|
</div>
|
2018-12-17 16:34:32 +00:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}}
|
2018-06-19 19:50:37 +00:00
|
|
|
</Subscribe>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Index
|