From ca520dd7859fb1ad231d47f35cbfb9a3f8318e50 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 9 May 2019 13:21:51 -0700 Subject: [PATCH] :bug: Reset timer on OnTicke change --- source/components/StyledCountdown/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/components/StyledCountdown/index.js b/source/components/StyledCountdown/index.js index d2417463..caad23ab 100644 --- a/source/components/StyledCountdown/index.js +++ b/source/components/StyledCountdown/index.js @@ -88,6 +88,10 @@ const StyledCountdown = ({ className, stop, onTick }) => { const [value, setValue] = useState(START); const timerShouldPlay = !stop && value > 0; + React.useEffect(() => { + setValue(START); + }, [onTick]); + useInterval(() => { const newValue = value - 1; setValue(newValue);