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