import { useState } from 'react'; function useLoading() { const [isLoading, setIsLoading] = useState(false); function setPromise(promise: Promise) { setIsLoading(true); promise .then(() => setIsLoading(false)) .catch(() => setIsLoading(false)); return promise; } return [isLoading, setPromise] as const; } export { useLoading };