AI

Debouncing is crucial for search inputs to avoid spamming your API. Let's encapsulate this logic in a reusable hook.

Your Task:

  • Implement useDebounce(value, delay)
  • It should return a debouncedValue that only updates after the delay has passed without changes
  • Use useEffect with a timeout and cleanup
  • This allows the UI to update instantly (input value) while the API call waits (debounced value)
TypeScript Solution
Loading...

Submit your code to see test results