-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathshallow.js
43 lines (40 loc) · 991 Bytes
/
shallow.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import Link from 'next/link'
import { useRouter } from 'next/router'
export default function Shallow({ message }) {
const { pathname, query } = useRouter()
return (
<div>
<ul>
<li id="message-contents">{message}</li>
<li>
<Link href="/sha?hello=world" shallow id="shallow-link">
Shallow link to ?hello=world
</Link>
</li>
<li>
<Link href="/sha?hello=goodbye" id="deep-link">
Deep link to ?hello=goodbye
</Link>
</li>
<li>
<h1 id="pathname">
Current path: <code>{pathname}</code>
</h1>
</li>
<li>
<h2 id="query" data-query-hello={query.hello}>
Current query: <code>{JSON.stringify(query)}</code>
</h2>
</li>
</ul>
</div>
)
}
let i = 0
export const getServerSideProps = () => {
return {
props: {
message: `Random: ${++i}${Math.random()}`,
},
}
}