import { useState } from "react" export function usePrevious(value: T): T | undefined { const [current, setCurrent] = useState(value) const [previous, setPrevious] = useState() if (value !== current) { setPrevious(current) setCurrent(value) } return previous }