1export function useLoading() {
2 const [isLoading, setState] = React.useState(false);
3 const load = (aPromise: Promise<any>) => {
4 setState(true);
5 return aPromise.finally(() => setState(false));
6 };
7 return [isLoading, load] as const; // infers [boolean, typeof load] instead of (boolean | typeof load)[]
8}