forked from vercel/next.js
/
page.js
42 lines (39 loc) · 777 Bytes
/
page.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
import { Suspense } from 'react'
import Counter from '../../components/partial-hydration-counter'
let result
let promise
function Data() {
if (result) {
try {
return result
} finally {
promise = null
result = null
}
}
if (!promise)
promise = new Promise((res) => {
setTimeout(() => {
result = 'next_streaming_data'
res()
}, 1000)
})
throw promise
}
export default function () {
return (
<>
{process.env.NEXT_RUNTIME === 'edge'
? `Runtime: Node.js`
: 'Runtime: Edge/Browser'}
<br />
<div className="suspense">
<Suspense fallback="next_streaming_fallback">
<Data />
</Suspense>
</div>
<br />
<Counter />
</>
)
}