File tree 1 file changed +14
-16
lines changed
examples/with-prefetching/components
1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react'
2
1
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'
12
3
13
4
export default ( ) => (
14
5
< div >
15
6
{ /* Prefetch using the declarative API */ }
16
7
< Link href = '/' >
17
- < a style = { styles . a } > Home</ a >
8
+ < a > Home</ a >
18
9
</ Link >
19
10
20
11
< Link href = '/features' >
21
- < a style = { styles . a } > Features</ a >
12
+ < a > Features</ a >
22
13
</ Link >
23
14
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 >
27
19
28
20
< Link href = '/contact' prefetch = { false } >
29
- < a style = { styles . a } > Contact (< small > NO-PREFETCHING</ small > )</ a >
21
+ < a > Contact (< small > NO-PREFETCHING</ small > )</ a >
30
22
</ Link >
23
+
24
+ < style jsx > { `
25
+ a {
26
+ margin-right: 10px;
27
+ }
28
+ ` } </ style >
31
29
</ div >
32
30
)
You can’t perform that action at this time.
0 commit comments