Files
bsky-social-app/src/components/hooks/useDelayedLoading.ts
T
2026-03-23 09:19:57 -07:00

15 lines
431 B
TypeScript

import {useEffect, useState} from 'react'
export function useDelayedLoading(delay: number, isActuallyLoading: boolean) {
const [isDelayActive, setIsDelayActive] = useState(isActuallyLoading)
useEffect(() => {
if (!isDelayActive) return
const timeout = setTimeout(() => setIsDelayActive(false), delay)
return () => clearTimeout(timeout)
}, [isDelayActive, delay])
return isDelayActive || isActuallyLoading
}