overleaf/services/web/frontend/js/shared/hooks/use-previous-value.js

10 lines
188 B
JavaScript
Raw Normal View History

import { useEffect, useRef } from 'react'
export default function usePreviousValue(value) {
const ref = useRef()
useEffect(() => {
ref.current = value
})
return ref.current
}