Skip to content

Commit 9056116

Browse files
authored
Update Header.js
1 parent 3766612 commit 9056116

File tree

1 file changed

+14
-16
lines changed
  • examples/with-prefetching/components

1 file changed

+14
-16
lines changed
+14-16
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
1-
import React from 'react'
21
import Link, { prefetch } from 'next/prefetch'
3-
4-
// Prefetch using the imperative API
5-
prefetch('/')
6-
7-
const styles = {
8-
a: {
9-
marginRight: 10
10-
}
11-
}
2+
import RegularLink from 'next/link'
123

134
export default () => (
145
<div>
156
{ /* Prefetch using the declarative API */ }
167
<Link href='/'>
17-
<a style={styles.a} >Home</a>
8+
<a>Home</a>
189
</Link>
1910

2011
<Link href='/features'>
21-
<a style={styles.a} >Features</a>
12+
<a>Features</a>
2213
</Link>
2314

24-
<Link href='/about'>
25-
<a style={styles.a} >About</a>
26-
</Link>
15+
{ /* we imperatively prefetch on hover */ }
16+
<RegularLink href='/about'>
17+
<a onMouseEnter={ () => prefetch('/about') && console.log('prefetching /about!') }>About</a>
18+
</RegularLink>
2719

2820
<Link href='/contact' prefetch={false}>
29-
<a style={styles.a} >Contact (<small>NO-PREFETCHING</small>)</a>
21+
<a>Contact (<small>NO-PREFETCHING</small>)</a>
3022
</Link>
23+
24+
<style jsx>{`
25+
a {
26+
margin-right: 10px;
27+
}
28+
`}</style>
3129
</div>
3230
)

0 commit comments

Comments
 (0)