Avoid overriding last api response
Hey!
I'm developing a react app with an input that makes calls to the google books API while you type.
The problem is that sometimes there is a response that takes longer than the last fetch and overrides it. I can solve it by increasing the delay time in the debounce function, but it is ugly that it is updated too late, or by sending abort signals that cancel the previous fetch request, but with this, the grid is not updating with the results while I write, so it doesn't looks good.
Is there any other approach I can follow?
2 Replies
Probably denouncing the users input and playing with the delay would solve the issue around having to mess with aborting signals and all that. How are you fetching data btw, using react query would really simplify ur fetching and dealing with stale data
it should also support aborting requests
i'm using fetch
I haven't used react query, I will give it a try, thanks!