Skip to content

Instantly share code, notes, and snippets.

View nvh95's full-sized avatar

Hung Viet Nguyen nvh95

View GitHub Profile
@nvh95
nvh95 / useEffectDebugger.js
Last active April 15, 2022 03:54
Find which dependency cause useEffect to fire
// Credit to https://stackoverflow.com/a/59843241/3422559
import { useEffect, useRef } from "react";
const usePrevious = (value, initialValue) => {
const ref = useRef(initialValue);
useEffect(() => {
ref.current = value;
});
return ref.current;