@supunlakmal/hooks
Version:
A collection of reusable React hooks
18 lines (17 loc) • 862 B
TypeScript
export interface UseIdleTimerProps {
onIdle: () => void;
onActive?: () => void;
timeout: number;
debounce?: number;
}
/**
* Custom hook to detect user inactivity.
*
* @param {UseIdleTimerProps} options - Configuration options.
* @param {() => void} options.onIdle - Callback function to execute when the user becomes idle.
* @param {() => void} [options.onActive] - Optional callback function to execute when the user becomes active after being idle.
* @param {number} options.timeout - Idle timeout duration in milliseconds.
* @param {number} [options.debounce=0] - Debounce time in milliseconds for handling frequent activity events.
* @returns {boolean} Returns the current idle state (`true` if idle, `false` otherwise).
*/
export declare const useIdleTimer: ({ onIdle, onActive, timeout, debounce, }: UseIdleTimerProps) => boolean;