From 74e41780c6da39d19b6c8d3e8474f3016c46bf4d Mon Sep 17 00:00:00 2001 From: FikiratJavadov Date: Sun, 31 Mar 2024 23:56:02 +0400 Subject: [PATCH] added deps as init value for prevDeps --- .../use-effect-hook-polyfill/src/hooks/use-custom-effect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reactjs-interview-questions/use-effect-hook-polyfill/src/hooks/use-custom-effect.js b/reactjs-interview-questions/use-effect-hook-polyfill/src/hooks/use-custom-effect.js index 01b1555..907452e 100644 --- a/reactjs-interview-questions/use-effect-hook-polyfill/src/hooks/use-custom-effect.js +++ b/reactjs-interview-questions/use-effect-hook-polyfill/src/hooks/use-custom-effect.js @@ -2,7 +2,7 @@ import {useRef} from "react"; const useCustomEffect = (effect, deps) => { const isFirstRender = useRef(true); - const prevDeps = useRef([]); + const prevDeps = useRef(deps ?? []); // First Render if (isFirstRender.current) {