mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-16 06:06:11 +01:00
11 lines
304 B
TypeScript
11 lines
304 B
TypeScript
import { useRef } from 'react';
|
|
import usePromise from 'react-promise-suspense';
|
|
|
|
/**
|
|
* A more stable alternative to `use` using `usePromise`.
|
|
*/
|
|
export function useAwait<Type>(promise: Promise<Type>) {
|
|
const callback = useRef(async () => await promise);
|
|
return usePromise(callback.current, []);
|
|
}
|