Snippet
usePrevious()
edit
import React from 'react'
function usePrevious(value) {
const ref = React.useRef(value)
React.useEffect(() => {
ref.current = value
}, [value])
return ref.current
}
Liked the post?
Give the author a dopamine boost with a few "beard strokes". Click the beard
up to 50 times to show your appreciation.
Kyle Shevlin is the founder & lead software engineer of Agathist, a software development firm with a mission to build good software with good people.