2021-11-15 16:33:57 +00:00
|
|
|
import { useEffect, useRef } from 'react'
|
|
|
|
|
2023-01-09 14:33:43 +00:00
|
|
|
export default function usePreviousValue<T>(value: T) {
|
|
|
|
const ref = useRef<T>()
|
2021-11-15 16:33:57 +00:00
|
|
|
useEffect(() => {
|
|
|
|
ref.current = value
|
|
|
|
})
|
|
|
|
return ref.current
|
|
|
|
}
|