2019-08-07 16:47:13 +02:00
|
|
|
import Link from 'next/link'
|
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
|
|
|
|
const invalidLink = 'https://google.com/another'
|
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const { query, ...router } = useRouter()
|
|
|
|
const { method } = query
|
|
|
|
|
|
|
|
return method ? (
|
|
|
|
<a
|
2019-11-11 04:24:53 +01:00
|
|
|
id="click-me"
|
2019-08-07 16:47:13 +02:00
|
|
|
onClick={e => {
|
|
|
|
e.preventDefault()
|
|
|
|
router[method](invalidLink)
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
invalid link :o
|
|
|
|
</a>
|
|
|
|
) : (
|
|
|
|
// this should throw an error on load since prefetch
|
|
|
|
// receives the invalid href
|
|
|
|
<Link href={invalidLink}>
|
2019-11-11 04:24:53 +01:00
|
|
|
<a id="click-me">invalid link :o</a>
|
2019-08-07 16:47:13 +02:00
|
|
|
</Link>
|
|
|
|
)
|
|
|
|
}
|