import { useState , useEffect } from 'react' ; returns { boolean } param time export default function useDelay ( time ) { const [ isResolve , setIsResolve ] = useState ( time <= 0 ) ; useEffect ( ( ) => { if ( time <= 0 ) return ; const timer = setTimeout ( ( ) => setIsResolve ( true ) , time ) ; return ( ) => clearTimeout ( timer ) ; } , [ ] ) ; return isResolve ; }