2018-09-14 10:04:29 +00:00
|
|
|
import React, { Component } from 'react'
|
2019-01-17 21:13:34 +00:00
|
|
|
import Link from 'next/link'
|
2018-09-14 10:04:29 +00:00
|
|
|
/* First we import the consumer */
|
|
|
|
import { CounterConsumer } from '../components/CounterProvider'
|
|
|
|
|
|
|
|
export default class index extends Component {
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
/* Then we use our context through render props */
|
|
|
|
<CounterConsumer>
|
|
|
|
{({ count, increase, decrease }) => (
|
|
|
|
<div>
|
2019-01-17 21:13:34 +00:00
|
|
|
<h1>HOME</h1>
|
2018-09-14 10:04:29 +00:00
|
|
|
<p>Counter: {count}</p>
|
|
|
|
<button onClick={increase}>Increase</button>
|
|
|
|
<button onClick={decrease}>Decrease</button>
|
2019-01-17 21:13:34 +00:00
|
|
|
<p><Link href='/about'>
|
|
|
|
<a>About</a>
|
|
|
|
</Link></p>
|
2018-09-14 10:04:29 +00:00
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</CounterConsumer>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|