mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
the "wait for 500ms" thing was a leftover of me inspecting the test apps visually, we don't need it anymore and it slows the tests down unnecessarily
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { Suspense } from 'react'
|
|
import { cachedDelay, uncachedIO } from '../../shared'
|
|
import { cookies } from 'next/headers'
|
|
|
|
export default function Page() {
|
|
return (
|
|
<main>
|
|
<h1 style={{ color: 'yellow' }}>Page one</h1>
|
|
<Suspense fallback={<div style={{ color: 'grey' }}>Loading 1...</div>}>
|
|
<RuntimePrefetchable />
|
|
</Suspense>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
async function RuntimePrefetchable() {
|
|
const cookieStore = await cookies()
|
|
const cookieValue = cookieStore.get('testCookie')?.value ?? null
|
|
await cachedDelay([__filename, cookieValue])
|
|
return (
|
|
<div style={{ border: '1px solid blue', padding: '1em' }}>
|
|
<div id="cookie-value-page">{`Cookie from page: ${cookieValue}`}</div>
|
|
<Suspense fallback={<div style={{ color: 'grey' }}>Loading 2...</div>}>
|
|
<Dynamic />
|
|
</Suspense>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
async function Dynamic() {
|
|
await uncachedIO()
|
|
return (
|
|
<div style={{ border: '1px solid tomato', padding: '1em' }}>
|
|
<div id="dynamic-content-page">Dynamic content from page one</div>
|
|
</div>
|
|
)
|
|
}
|