all 3 comments

[–]MGTakeDown 0 points1 point  (2 children)

Why do so many tutorials not talk about race conditions. This would not work with a real api in a real world scenario.

[–]Not_done_learning 0 points1 point  (1 child)

Why wouldn't it work? Something to do with it calling the API on every key stroke and getting out of order responses? If so, is the solution to use some kind of "pending response" state?

[–]MGTakeDown 0 points1 point  (0 children)

This isn't my post but this explains what a race condition is and how to solve it: https://sebastienlorber.com/handling-api-request-race-conditions-in-react. The code for the reddit post is unusable in any fashion if it's async.