MCPcopy Create free account
hub / github.com/cosscom/coss / useLoadingState

Function useLoadingState

apps/examples/calcom/hooks/use-loading-state.ts:9–25  ·  view source on GitHub ↗
(delayMs: number)

Source from the content-addressed store, hash-verified

7 * @returns Whether to show the loading state
8 */
9export function useLoadingState(delayMs: number) {
10 const { enableArtificialDelay, isLoadingOverride } = useDebug();
11 const [isLoading, setIsLoading] = useState(enableArtificialDelay);
12
13 useEffect(() => {
14 if (!enableArtificialDelay) {
15 setIsLoading(false);
16 return;
17 }
18 const timer = setTimeout(() => {
19 setIsLoading(false);
20 }, delayMs);
21 return () => clearTimeout(timer);
22 }, [enableArtificialDelay, delayMs]);
23
24 return isLoadingOverride ?? isLoading;
25}

Callers 7

EventTypesListFunction · 0.90
BookingsListFunction · 0.90
BookingsListFunction · 0.90
BookingsEmptyFunction · 0.90
BookingsEmptyFunction · 0.90
BookingsEmptyFunction · 0.90
BookingsEmptyFunction · 0.90

Calls 1

useDebugFunction · 0.90

Tested by

no test coverage detected