-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fetching too quickly causes race conditions #302
Comments
This happened to me a couple of times. The temporary workaround I had is to create a map where the keys are URLs and the values are But it would be great if this is fixed in the library. |
Is this a matter of calling |
I'm trying with |
Yes |
…he latest request
Describe the bug
Invoking the
get
function too quickly in a short amount of time causes race conditions.https://codesandbox.io/s/use-http-race-conditions-ecnqt?file=/src/App.js
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I know this is a heavily contrived example, but it essentially mirrors the behavior I'm experiencing in a production app. A date picker has arrow buttons that allow the user to quickly change date query params that fire off a new useFetch request with each click. If the user clicks too quickly, then 90% of the time, I'll end up with UI that shows previous request data. After some amount of time (sometimes 30 seconds to a minute) the UI eventually updates to reflect the latest request data.
Note: I tried using the
abort
function exposed fromuseFetch
to abort all previous requests, but this seems to abort only every other previous request or so.The text was updated successfully, but these errors were encountered: