mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
8 lines
240 B
TypeScript
8 lines
240 B
TypeScript
import { useRef, useEffect } from 'react'
|
|
|
|
export function usePreviousValue<T>(value: T): T | undefined {
|
|
const prevRef = useRef<T | undefined>(undefined)
|
|
useEffect(() => { prevRef.current = value }, [value])
|
|
return prevRef.current
|
|
}
|