this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at e28f6d2f370b4e882ed6f23d08ca0f8d94dbac5f 15 lines 486 B view raw
1import {useEffect, useState} from 'react' 2 3export function useDelayedLoading(delay: number, initialState: boolean = true) { 4 const [isLoading, setIsLoading] = useState(initialState) 5 6 useEffect(() => { 7 let timeout: NodeJS.Timeout 8 // on initial load, show a loading spinner for a hot sec to prevent flash 9 if (isLoading) timeout = setTimeout(() => setIsLoading(false), delay) 10 11 return () => timeout && clearTimeout(timeout) 12 }, [isLoading, delay]) 13 14 return isLoading 15}