{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "use-debounce", "description": "A hook to debounce rapidly changing values", "dependencies": [], "devDependencies": [], "registryDependencies": [], "files": [ { "path": "packages/hooks/use-debounce/index.ts", "content": "import { useEffect, useState } from \"react\";\n\nexport function useDebounce(value: T, delay: number = 500): T {\n\tconst [debouncedValue, setDebouncedValue] = useState(value);\n\n\tuseEffect(() => {\n\t\t// Set up the timeout\n\t\tconst handler = setTimeout(() => {\n\t\t\tsetDebouncedValue(value);\n\t\t}, delay);\n\n\t\t// Clean up the timeout if value changes before delay\n\t\treturn () => {\n\t\t\tclearTimeout(handler);\n\t\t};\n\t}, [value, delay]);\n\n\treturn debouncedValue;\n}\n", "type": "registry:hook", "target": "hooks/use-debounce.tsx" } ], "type": "registry:hook" }