From d2bb09dce82fe383cb755723d234255d410a417c Mon Sep 17 00:00:00 2001 From: Ward Oosterlijnck Date: Sun, 31 Mar 2019 19:30:22 +1100 Subject: [PATCH] Remove ref implementation useEffectOnce --- src/useEffectOnce.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/useEffectOnce.ts b/src/useEffectOnce.ts index 50badc6d83..65a411e6d7 100644 --- a/src/useEffectOnce.ts +++ b/src/useEffectOnce.ts @@ -1,14 +1,7 @@ -import {useRef, useEffect, EffectCallback} from 'react'; +import {useEffect, EffectCallback} from 'react'; const useEffectOnce = (effect: EffectCallback) => { - const didRun = useRef(false); - - useEffect(() => { - if (!didRun.current) { - didRun.current = true; - return effect(); - } - }); + useEffect(effect, []); } export default useEffectOnce;