@supunlakmal/hooks
Version:
A collection of reusable React hooks
31 lines (30 loc) • 1.16 kB
TypeScript
interface CountdownOptions {
/** Initial number of seconds for the countdown. */
seconds: number;
/** Interval in milliseconds for the countdown updates (default: 1000). */
interval?: number;
/** Callback function executed when the countdown completes. */
onComplete?: () => void;
/** Start the countdown automatically on mount (default: true). */
autoStart?: boolean;
}
interface CountdownControls {
/** Current remaining seconds. */
remainingSeconds: number;
/** Boolean indicating if the countdown is currently running. */
isRunning: boolean;
/** Function to start or resume the countdown. */
start: () => void;
/** Function to pause the countdown. */
pause: () => void;
/** Function to reset the countdown to the initial seconds. */
reset: () => void;
}
/**
* Manages a countdown timer with start, pause, and reset controls.
*
* @param options Configuration options for the countdown timer.
* @returns Controls and state for the countdown timer.
*/
export declare const useCountdown: ({ seconds, interval, onComplete, autoStart, }: CountdownOptions) => CountdownControls;
export {};