mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-24 15:08:44 -05:00
* Initial * CSS lint * Test CI * Add 1v1, 2v2, and 3v3 Tags (#1771) * Initial * CSS lint * Test CI * Rename step --------- Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
19 lines
465 B
TypeScript
19 lines
465 B
TypeScript
import * as React from "react";
|
|
|
|
/** Forces the component to rerender periodically*/
|
|
export function useAutoRerender(every?: "second" | "ten seconds") {
|
|
const [, setNow] = React.useState(new Date().getTime());
|
|
|
|
React.useEffect(() => {
|
|
const intervalTime = !every || every === "second" ? 1000 : 10000;
|
|
|
|
const interval = setInterval(() => {
|
|
setNow(new Date().getTime());
|
|
}, intervalTime);
|
|
|
|
return () => {
|
|
clearInterval(interval);
|
|
};
|
|
}, [every]);
|
|
}
|