Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

505 B
Raw Blame
"use client";

import { useEffect, useState } from "react";

/**
 * Debounce a rapidly-changing value. Presentational hook — safe to use
 * inside `@repowise-dev/ui` shells (no data fetching, no framework
 * coupling).
 */
export function useDebounce<T>(value: T, delay: number): T {
  const [debounced, setDebounced] = useState(value);
  useEffect(() => {
    const timer = setTimeout(() => setDebounced(value), delay);
    return () => clearTimeout(timer);
  }, [value, delay]);
  return debounced;
}