import { useEffect, useState } from 'react'; export function useDelayResetState( theValue: T, startDelay: number, delay: number ) { const [value, setValue] = useState(null); useEffect(() => { const handler1 = setTimeout(() => { setValue(theValue); }, startDelay); const handler2 = setTimeout(() => { setValue(null); }, startDelay + delay); return () => { clearTimeout(handler1); clearTimeout(handler2); }; }, [setValue, theValue, delay, startDelay]); return value; }