mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
Write to a marker file to determine when the slow server component finishes rendering instead of trying to sleep for some fixed amount of time.
33 lines
896 B
TypeScript
33 lines
896 B
TypeScript
import { Suspense } from 'react'
|
|
import { connection } from 'next/server'
|
|
import { HydrationIndicator } from '../../hydration-indicator'
|
|
import waitForMarkerFile from '../../../waitForMarkerFile'
|
|
|
|
export default function Page() {
|
|
return (
|
|
<main id="shell">
|
|
<h1>This is a page with static shell + no streaming metadata</h1>
|
|
<div>
|
|
<p>Static shell</p>
|
|
<HydrationIndicator id="shell-hydrated" />
|
|
<hr />
|
|
<Suspense fallback={<div id="dynamic-fallback">Loading...</div>}>
|
|
<SlowServerComponent />
|
|
</Suspense>
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
async function SlowServerComponent() {
|
|
await connection()
|
|
await waitForMarkerFile()
|
|
const randomValue = Math.floor(Math.random() * 1000)
|
|
return (
|
|
<div id="dynamic">
|
|
<div>{`Random value: ${randomValue}`}</div>
|
|
<HydrationIndicator id="dynamic-hydrated" />
|
|
</div>
|
|
)
|
|
}
|