import { useEffect, useRef } from "preact/hooks"; export function usePrevious(value: T): T|undefined { const ref = useRef(); useEffect(() => { ref.current = value; }, [value]); return ref.current as T|undefined; }