Skip to content

## FRONTEND: Add useDebounce Hook for Search Inputs #1056

Description

@OSEH-svg

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).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions