2017-08-30 16:07:12 +02:00
|
|
|
import { withRouter } from 'next/router'
|
|
|
|
|
2019-02-19 22:45:07 +01:00
|
|
|
const Link = withRouter(({ router, children, href }) => {
|
2019-05-30 03:19:32 +02:00
|
|
|
const handleClick = e => {
|
2017-08-30 16:07:12 +02:00
|
|
|
e.preventDefault()
|
|
|
|
router.push(href)
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2019-11-11 04:24:53 +01:00
|
|
|
<span id="pathname">Current path: {router.pathname}</span>
|
|
|
|
<span id="asPath">Current asPath: {router.asPath}</span>
|
|
|
|
<a href="#" onClick={handleClick}>
|
2019-05-30 03:19:32 +02:00
|
|
|
{children}
|
|
|
|
</a>
|
2017-08-30 16:07:12 +02:00
|
|
|
</div>
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
export default () => (
|
2019-11-11 04:24:53 +01:00
|
|
|
<div className="nav-with-hoc">
|
|
|
|
<Link href="/nav">Go Back</Link>
|
2017-08-30 16:07:12 +02:00
|
|
|
<p>This is the about page.</p>
|
|
|
|
</div>
|
|
|
|
)
|