Search uses stale query
Review this React TypeScript component.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 25 min
Mark a line and say what kind of problem it is.0 findings
1function SearchBox({ onSearch }: { onSearch: (q: string) => void }) {
2 const [query, setQuery] = useState('');
3
4 const debouncedSearch = useCallback(
5 debounce(() => onSearch(query), 300),
6 []
7 );
8
9 return (
10 <input
11 value={query}
12 onChange={(e) => {
13 setQuery(e.target.value);
14 debouncedSearch();
15 }}
16 />
17 );
18}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.