diff --git a/src/useUpdateEffect.ts b/src/useUpdateEffect.ts index f4f5661954..47678266bc 100644 --- a/src/useUpdateEffect.ts +++ b/src/useUpdateEffect.ts @@ -3,14 +3,13 @@ import { useEffect, useRef } from 'react'; const useUpdateEffect: typeof useEffect = (effect, deps) => { const isInitialMount = useRef(true); - useEffect( - isInitialMount.current - ? () => { - isInitialMount.current = false; - } - : effect, - deps - ); + useEffect(() => { + if (isInitialMount.current) { + isInitialMount.current = false; + } else { + effect(); + } + }, deps); }; export default useUpdateEffect;