|
@@ -61,11 +61,12 @@ const PasswordConfirm = ({min=8}) => {
|
|
|
|
|
|
const Timer = ({seconds=10}) => {
|
|
|
let [time=seconds, setTime] = useState();
|
|
|
- if(time > 0) {
|
|
|
- setTimeout(()=> setTime(time - 1), 1000)
|
|
|
-
|
|
|
+ //setTimeout(()=> setTime(time - 1), 1000)
|
|
|
+ useEffect(() => {
|
|
|
+ const interval = setInterval(()=> setTime(time - 1), 1000)
|
|
|
+ return() => {clearInterval(interval)}
|
|
|
+ },[time])
|
|
|
//сделать интервал завернуть в юхефект и незабыть клир
|
|
|
- }
|
|
|
return (
|
|
|
<strong>
|
|
|
{Math.floor(((time*1000) / (1000 * 60 * 60)) % 24)} :
|