Skip to content

Instantly share code, notes, and snippets.

@dariovr1
dariovr1 / js
Created September 8, 2020 15:51
React Hooks BetterUseEffect - A replacement of useEffect
import { useEffect, useRef } from "react";
export const usePrevious = (value) => {
const ref = useRef();
useEffect(() => {
ref.current = value;
});
return ref.current;
}