import { useSyncExternalStore } from 'react' import type { ResolvedCached } from './Cache' import type { CacheKey, CacheOptions } from './types' import { useCache } from './useCache' /** * @experimental This is experimental feature. */ export function useRead( options: CacheOptions ): ResolvedCached['state'] { const cache = useCache() return useSyncExternalStore>( cache.subscribe, () => cache.suspend(options), () => cache.suspend(options) ).state }