File size: 559 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { withRouter } from 'next/router'

const Link = withRouter(({ router, children, href }) => {
  const handleClick = (e) => {
    e.preventDefault()
    router.push(href)
  }

  return (
    <div>
      <span id="pathname">Current path: {router.pathname}</span>
      <span id="asPath">Current asPath: {router.asPath}</span>
      <a href="#" onClick={handleClick}>
        {children}
      </a>
    </div>
  )
})

export default () => (
  <div className="nav-with-hoc">
    <Link href="/nav">Go Back</Link>
    <p>This is the about page.</p>
  </div>
)