mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
15 lines
435 B
TypeScript
15 lines
435 B
TypeScript
'use client'
|
|
|
|
import { use } from 'react'
|
|
import { useDataCache } from '../../../../client-data-fetching-lib/client'
|
|
|
|
export function FetchesClientData() {
|
|
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>
|
|
}
|