import { use } from "react"; const cache = new Map>(); export function useAwait( creator: () => Promise, discriminator: string ) { let promise; if (cache.has(discriminator)) { promise = cache.get(discriminator) as Promise; } else { promise = creator(); cache.set(discriminator, promise); } return use(promise); }