Created
July 31, 2024 15:01
-
-
Save satyam4p/f4aaafa80fdad8fa0fbf0a9deca3a390 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useRef } from "react"; | |
const usePrevious = (value) => { | |
const ref = useRef(); | |
useEffect(() => { | |
ref.current = value; | |
}, [value]); | |
return ref.current; | |
}; | |
export default usePrevious; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment