konnos
Dashboard
flndrn
Briven
apps
studio
hooks
misc
useLatest.ts
useLatest.ts
9 lines ·
main
1
import { useRef } from 'react'
2
3
export const useLatest = <T>(value: T): { readonly current: T } => {
4
const ref = useRef(value)
5
ref.current = value
6
return ref
7
}
8
9
export default useLatest