Skip to content

Commit

Permalink
Removed any and added hook documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Aug 21, 2024
1 parent 28102c6 commit d377775
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Components/Files/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import useFileManager from "../../Utils/useFileManager.js";
import Tabs from "../Common/components/Tabs.js";
import FileBlock from "./FileBlock.js";

export const LinearProgressWithLabel = (props: any) => {
export const LinearProgressWithLabel = (props: { value: number }) => {
return (
<div className="flex align-middle">
<div className="my-auto mr-2 w-full">
Expand Down Expand Up @@ -51,7 +51,7 @@ export interface ModalDetails {
id?: string;
reason?: string;
userArchived?: string;
archiveTime?: any;
archiveTime?: string;
associatedId?: string;
}

Expand Down
25 changes: 23 additions & 2 deletions src/Utils/useTimer.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
import { useEffect, useState } from "react";

/**
* Custom hook to manage a timer in MM:SS format. This can be useful for tracking time during recording sessions, user actions, or any other timed event.
*
* @returns {Object} A set of properties and methods to control and display the timer:
*
* @property {number} seconds - The total elapsed time in seconds.
* @property {JSX.Element} time - A JSX element displaying the current time in MM:SS format.
* @property {function} start - Function to start the timer.
* @property {function} stop - Function to stop the timer.
*
* @example
* const { time, start, stop } = useTimer();
*
* // To start the timer:
* start();
*
* // To stop the timer:
* stop();
*
* // To display the timer in your component:
* <div>{time}</div>
*/
export const useTimer = () => {
const [running, setRunning] = useState(false);
const [time, setTime] = useState(0);

useEffect(() => {
let interval: any;
let interval: NodeJS.Timeout;
if (running) {
interval = setInterval(() => {
setTime((prevTime) => prevTime + 1);
}, 10);
} else {
clearInterval(interval);
setTime(0);
}
return () => clearInterval(interval);
Expand Down

0 comments on commit d377775

Please sign in to comment.