medium10 pts · first answer countsreactrace-conditionsdata-fetching
Search shows results for old input
Typing "react" quickly sometimes shows results for "re", because that slower response arrives last. What is the best fix in this effect?
useEffect(() => {
fetch('/api/search?q=' + encodeURIComponent(query))
.then((r) => r.json())
.then(setResults)
}, [query])Discussion 0
Join free to post in the discussion.
Related questions
- Keys for rows loaded from an APIFull Stack Developer
- Fetching data in a pageFull Stack Developer
- Reading cookies in a Server ComponentFull Stack Developer
- Fetching two things at onceFull Stack Developer
- User bios rendered as HTMLFull Stack Developer
- Relative fetch on the serverFull Stack Developer
- Same DB query in layout and pageFull Stack Developer
- Same fetch called twiceFull Stack Developer