Description
The Discover page and future search inputs trigger API calls on every keystroke. Issue #720 called for debounced search and was closed, but the hooks/ directory contains no useDebounce.ts file. The hook was never actually added to the repository.
Tasks
- Create
hooks/useDebounce.ts with a generic useDebounce<T>(value: T, delay: number): T implementation.
- Apply it to the search input on the Discover page.
- Add a unit test in
__tests__/use-debounce.test.ts.
Acceptance Criteria
hooks/useDebounce.ts exists and exports the hook.
- The Discover page search input debounces API calls at 300ms.
- Unit test covers: value updates before delay (should not change), value updates after delay (should change).
Description
The Discover page and future search inputs trigger API calls on every keystroke. Issue #720 called for debounced search and was closed, but the
hooks/directory contains nouseDebounce.tsfile. The hook was never actually added to the repository.Tasks
hooks/useDebounce.tswith a genericuseDebounce<T>(value: T, delay: number): Timplementation.__tests__/use-debounce.test.ts.Acceptance Criteria
hooks/useDebounce.tsexists and exports the hook.