Skip to content

Instantly share code, notes, and snippets.

@gabor-paholics-benestudio
Created April 30, 2021 13:02
function usePrevious<T>(value: T): T | undefined {
const ref = useRef<T>();
useEffect(() => {
ref.current = value;
});
return ref.current;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment