Created
July 30, 2020 08:39
-
-
Save dimitrinicolas/4241b990d542e1e97cd40b3baba5f921 to your computer and use it in GitHub Desktop.
Revisions
-
dimitrinicolas created this gist
Jul 30, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import { useRef, useEffect, EffectCallback, DependencyList } from 'react'; /** * @param {EffectCallback} effect * @param {DependencyList} [deps] */ export const useEffectNotFirst = (effect, deps) => { const firstUpdate = useRef(true); useEffect(() => { if (firstUpdate.current) { firstUpdate.current = false; return; } effect(); }, deps); };