Symptom
The search bar has a debounce mechanism -- it waits 300ms after the user stops typing before calling onSearch. But onSearch always receives an empty string or null, regardless of what the user typed.
Expected
After the debounce delay, onSearch should be called with the text the user typed.
What you know
The event handler reads e.target.value inside a setTimeout. In React versions before 17, synthetic events are pooled and recycled -- accessing event properties asynchronously returns null. Even in newer React, reading from the event in an async context is unreliable.
Hints
TypeScript
TypeScript ready
Test Output
▶
Click "Run Tests" to execute your code