mirror of
https://github.com/makeplane/plane.git
synced 2026-02-25 04:35:21 +01:00
26 lines
551 B
TypeScript
26 lines
551 B
TypeScript
/**
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* See the LICENSE file for details.
|
|
*/
|
|
|
|
import { useState, useEffect } from "react";
|
|
|
|
const TIMER = 30;
|
|
|
|
const useTimer = (initialValue: number = TIMER) => {
|
|
const [timer, setTimer] = useState(initialValue);
|
|
|
|
useEffect(() => {
|
|
const interval = setInterval(() => {
|
|
setTimer((prev) => prev - 1);
|
|
}, 1000);
|
|
|
|
return () => clearInterval(interval);
|
|
}, []);
|
|
|
|
return { timer, setTimer };
|
|
};
|
|
|
|
export default useTimer;
|