rsnext/examples/with-mobx-react-lite/components/Page.js
Corbin Crutchley e03266008c form handler example: Update deps and fix build from dep update (#6732)
* form handler example: Update deps and fix build from dep update

* Ran lint error fixers

* Fixes errors that occur when commit occurs

* Commit linter fixes
2019-03-27 16:12:45 -04:00

30 lines
622 B
JavaScript

import { useObserver } from 'mobx-react-lite'
import Link from 'next/link'
import { useContext, useEffect } from 'react'
import { StoreContext, start, stop } from '../store'
import Clock from './Clock'
function Page ({ linkTo, title }) {
const store = useContext(StoreContext)
useEffect(() => {
start()
return stop
}, [])
return (
<div>
<h1>{title}</h1>
{useObserver(() => (
<Clock lastUpdate={store.lastUpdate} light={store.light} />
))}
<nav>
<Link href={linkTo}>
<a>Navigate</a>
</Link>
</nav>
</div>
)
}
export default Page