Created
December 18, 2021 08:43
-
-
Save 0xLDev/2fb269629959dfc20c85e1694fa3d640 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
export const usePrevious = (value) => { | |
const refContainer = useRef(value); | |
useEffect(() => { | |
refContainer.current = value; | |
}, [value]); | |
return refContainer.current; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment