1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/with-context-api/pages/about.js

28 lines
760 B
JavaScript
Raw Normal View History

import React, { Component } from 'react'
/* First we import the consumer */
import { CounterConsumer } from '../components/CounterProvider'
import Link from 'next/link'
export default class about extends Component {
render () {
return (
/* Then we use our context through render props */
<CounterConsumer>
{({ count, increase, increaseBy }) => (
<div>
<h1>ABOUT</h1>
<p>Counter: {count}</p>
<button onClick={increase}>Increase</button>
<button onClick={() => {
increaseBy(15)
}}>Increase By 15</button>
<p><Link href='/'>
<a>Home</a>
</Link></p>
</div>
)}
</CounterConsumer>
)
}
}