rsnext/examples/with-context-api/pages/index.js

33 lines
665 B
JavaScript
Raw Normal View History

import Link from 'next/link'
import { useCount, useDispatchCount } from '../components/Counter'
const IndexPage = () => {
const count = useCount()
const dispatch = useDispatchCount()
2020-05-18 21:24:37 +02:00
const handleIncrease = (event) =>
dispatch({
type: 'INCREASE',
})
2020-05-18 21:24:37 +02:00
const handleDecrease = (event) =>
dispatch({
type: 'DECREASE',
})
return (
<>
<h1>HOME</h1>
<p>Counter: {count}</p>
<button onClick={handleIncrease}>Increase</button>
<button onClick={handleDecrease}>Decrease</button>
<p>
<Link href="/about">
<a>About</a>
</Link>
</p>
</>
)
}
export default IndexPage