-
Notifications
You must be signed in to change notification settings - Fork 28.1k
/
Copy pathindex.tsx
40 lines (37 loc) · 877 Bytes
/
index.tsx
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
import { useState } from 'react'
import Link from 'next/link'
import type { GetStaticProps } from 'next'
type Props = {
random: number
draftMode: string
}
export const getStaticProps: GetStaticProps<Props> = ({ draftMode }) => {
return {
props: {
random: Math.random(),
draftMode: Boolean(draftMode).toString(),
},
revalidate: 100000,
}
}
export default function Home(props: Props) {
const [count, setCount] = useState(0)
return (
<>
<h1>Home</h1>
<p>
Draft Mode: <em id="draft">{props.draftMode}</em>
</p>
<button id="inc" onClick={() => setCount(count + 1)}>
Increment
</button>
<p>
Count: <span id="count">{count}</span>
</p>
<p>
Random: <em id="rand">{props.random}</em>
</p>
<Link href="/another">Visit another page</Link>
</>
)
}