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-prefetching/components/Header.js

40 lines
720 B
JavaScript
Raw Normal View History

import Router from 'next/router'
import Link from 'next/link'
export default () => (
<div>
{/* Prefetch using the declarative API */}
<Link prefetch href='/'>
2016-12-20 20:44:23 +00:00
<a>Home</a>
</Link>
<Link prefetch href='/features'>
2016-12-20 20:44:23 +00:00
<a>Features</a>
</Link>
{/* we imperatively prefetch on hover */}
<Link href='/about'>
<a
onMouseEnter={() => {
Router.prefetch('/about')
console.log('prefetching /about!')
}}
>
About
</a>
</Link>
<Link href='/contact'>
<a>
Contact (<small>NO-PREFETCHING</small>)
</a>
</Link>
2016-12-20 20:44:23 +00:00
<style jsx>{`
a {
margin-right: 10px;
}
`}</style>
</div>
)