From 96259f7f58350593aec06bc992be06eef625df30 Mon Sep 17 00:00:00 2001 From: David Bonnet Date: Thu, 2 Nov 2023 09:26:06 +0100 Subject: [PATCH] Add `usePromise` documentation --- lib/hooks/usePromise.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/hooks/usePromise.ts b/lib/hooks/usePromise.ts index 740dbc2e..3cda3e42 100644 --- a/lib/hooks/usePromise.ts +++ b/lib/hooks/usePromise.ts @@ -12,6 +12,13 @@ type PromiseState = { reason?: Error; }; +/** + * Returns a promise state object to track the provided `promise`. + * Ignores outdated promises or ones that resolve when the component got unmounted. + * + * @param promise The promise to track. + * @returns A promise state object + */ export function usePromise(promise?: Promise | T) { const { 0: state, 1: onChangeState } = useState>({ status: "idle",