import {useEffect, useState} from 'react'

// false, then true after ms
export const useTimeoutFlag = (ms: number): boolean => {
  const [elapsed, setElapsed] = useState(false)
  useEffect(() => {
    const id = setTimeout(() => setElapsed(true), ms)
    return () => clearTimeout(id)
  }, [ms])
  return elapsed
}
