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

31 lines
675 B
JavaScript
Raw Normal View History

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