upcoming tournament page, minor changes
This commit is contained in:
18
src/hooks/use-now.ts
Normal file
18
src/hooks/use-now.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
const useNow = () => {
|
||||
const [now, setNow] = useState(new Date());
|
||||
|
||||
useEffect(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
setNow(new Date());
|
||||
}, 1000);
|
||||
|
||||
return () => clearInterval(intervalId);
|
||||
}, []);
|
||||
|
||||
return now;
|
||||
}
|
||||
|
||||
|
||||
export default useNow;
|
||||
Reference in New Issue
Block a user