|
@@ -1,4 +1,4 @@
|
|
-import React from "react";
|
|
|
|
|
|
+import React, { useEffect } from "react";
|
|
import styled from "styled-components";
|
|
import styled from "styled-components";
|
|
import ms from "pretty-ms";
|
|
import ms from "pretty-ms";
|
|
import useCountdown from "../../../hooks/useCountdown";
|
|
import useCountdown from "../../../hooks/useCountdown";
|
|
@@ -15,9 +15,13 @@ const TimedOut = styled(TimerSpan)`
|
|
|
|
|
|
export default ({ seconds, onTimeout }) => {
|
|
export default ({ seconds, onTimeout }) => {
|
|
const [remaining] = useCountdown(seconds, () => onTimeout());
|
|
const [remaining] = useCountdown(seconds, () => onTimeout());
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ if (remaining > 0) {
|
|
|
|
+ saveTimerToLocalStorage(remaining);
|
|
|
|
+ }
|
|
|
|
+ }, [remaining]);
|
|
|
|
|
|
if (remaining > 0) {
|
|
if (remaining > 0) {
|
|
- saveTimerToLocalStorage(remaining);
|
|
|
|
return <TimerSpan>Time: {ms(remaining * 1000)}</TimerSpan>;
|
|
return <TimerSpan>Time: {ms(remaining * 1000)}</TimerSpan>;
|
|
}
|
|
}
|
|
|
|
|