react-timer-hook
Version:
React timer hook is a custom react hook built to handle timers(countdown), stopwatch and time logic/state in your react component.
14 lines (13 loc) • 523 B
TypeScript
import { TimeFromMillisecondsType } from './utils/Time';
export type useStopwatchSettingsType = {
autoStart?: boolean;
offsetTimestamp?: Date;
interval?: number;
};
export type useStopwatchResultType = TimeFromMillisecondsType & {
start: () => void;
pause: () => void;
reset: (offset?: Date, newAutoStart?: boolean) => void;
isRunning: boolean;
};
export default function useStopwatch({ autoStart, offsetTimestamp, interval: customInterval }?: useStopwatchSettingsType): useStopwatchResultType;