-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
483 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import { useEffect, useState } from "react" | ||
import { useNavigate } from "react-router-dom" | ||
// import { useEffect, useState } from "react" | ||
// import { useNavigate } from "react-router-dom" | ||
|
||
export function CountdownPage() { | ||
const navigate = useNavigate() | ||
const [count, setCount] = useState(3) | ||
const [startTime, setStartTime] = useState(new Date()) | ||
// export function CountdownPage() { | ||
// const navigate = useNavigate() | ||
// const [count, setCount] = useState(3) | ||
// const [startTime, setStartTime] = useState(new Date()) | ||
|
||
useEffect(() => { | ||
if (count <= 0) { | ||
navigate('/') | ||
} | ||
}, [count]) | ||
// useEffect(() => { | ||
// if (count <= 0) { | ||
// navigate('/') | ||
// } | ||
// }, [count]) | ||
|
||
useEffect(() => { | ||
setInterval(() => { | ||
const mls = startTime.getTime() - new Date().getTime() | ||
console.log(mls) | ||
setCount((cnt) => 3 - Math.round(Math.abs(mls / 1000))) | ||
}, 980) | ||
}, []) | ||
// useEffect(() => { | ||
// setInterval(() => { | ||
// const mls = startTime.getTime() - new Date().getTime() | ||
// console.log(mls) | ||
// setCount((cnt) => 3 - Math.round(Math.abs(mls / 1000))) | ||
// }, 980) | ||
// }, []) | ||
|
||
return ( | ||
<div className="flex w-full h-full justify-center items-center align-middle font-bold text-6xl animate-ping duration-1000 "> | ||
{count} | ||
</div> | ||
) | ||
} | ||
// return ( | ||
// <div className="flex w-full h-full justify-center items-center align-middle font-bold text-6xl animate-ping duration-1000 "> | ||
// {count} | ||
// </div> | ||
// ) | ||
// } |
Oops, something went wrong.