mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
21 lines
504 B
TypeScript
21 lines
504 B
TypeScript
'use client'
|
|
|
|
import { use } from 'react'
|
|
import { useDataCache } from '../../../../client-data-fetching-lib/client'
|
|
|
|
export function FetchesClientData({ children }) {
|
|
const dataCache = useDataCache()
|
|
const promise = dataCache.getOrLoad('my-key', async () => {
|
|
await new Promise<void>((resolve) => setTimeout(resolve, 10))
|
|
return 'My client data result'
|
|
})
|
|
const data = use(promise)
|
|
return (
|
|
<>
|
|
<div>Got client data: "{data}"</div>
|
|
<hr />
|
|
{children}
|
|
</>
|
|
)
|
|
}
|