System Design Quiz Practice
Active Recall Drill Session
← Exit SessionQuestion 1 of 1
hardSystem Design
What does the `cancelled` flag inside the SearchBox's useEffect cleanup function protect against?
code
useEffect(() => {
let cancelled = false;
fetchResults(query).then((r) => { if (!cancelled) setResults(r); });
return () => { cancelled = true; };
}, [query]);