From 1dd0f68eb7778093376a57dd74da5fd5fdb559d4 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 23 Apr 2020 14:57:39 +0700 Subject: [PATCH] fixed hero timer --- src/components/flow/FlowHero/index.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/flow/FlowHero/index.tsx b/src/components/flow/FlowHero/index.tsx index b19c70a7..05c4a9cf 100644 --- a/src/components/flow/FlowHero/index.tsx +++ b/src/components/flow/FlowHero/index.tsx @@ -16,7 +16,6 @@ const FlowHeroUnconnected: FC = ({ heroes, history }) => { const [limit, setLimit] = useState(Math.min(heroes.length, 6)); const [current, setCurrent] = useState(0); const [loaded, setLoaded] = useState([]); - const [is_mobile, setIsMobile] = useState(false); const timer = useRef(null); const onLoad = useCallback(id => () => setLoaded([...loaded, id]), [setLoaded, loaded]); @@ -48,8 +47,10 @@ const FlowHeroUnconnected: FC = ({ heroes, history }) => { useEffect(() => { timer.current = setTimeout(onNext, 5000); - return () => clearTimeout(timer.current); - }, [current]); + return () => { + clearTimeout(timer.current); + }; + }, [current, onNext]); useEffect(() => { if (current === 0 && loaded.length > 0) setCurrent(loaded[0]);