📅  最后修改于: 2022-03-11 14:48:16.477000             🧑  作者: Mango
export function useLoading() {
const [isLoading, setState] = React.useState(false);
const load = (aPromise: Promise) => {
setState(true);
return aPromise.finally(() => setState(false));
};
return [isLoading, load] as const; // infers [boolean, typeof load] instead of (boolean | typeof load)[]
}