Bluesky app fork with some witchin' additions 馃挮
at 35fa3d8fdbcad84d6f810abb2d0cb65e6549a9fe 15 lines 482 B view raw
1import React from 'react' 2 3export function useDelayedLoading(delay: number, initialState: boolean = true) { 4 const [isLoading, setIsLoading] = React.useState(initialState) 5 6 React.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}