facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.41k stars 1.83k forks source link

useRefetchableFragment refetch disposable doesn't cancel network request #4252

Open horne3754sg opened 1 year ago

horne3754sg commented 1 year ago

As per the title, I have looked at the documents which states:

disposable: Object containing a dispose function. Calling disposable.dispose() will cancel the refetch request.

But I cannot seem to get the request to cancel. In my use case, I have a date picker which you can toggle next/prev. When click next multiple times, it will send out multiple network requests instead of cancelling the previous request.

I use an effect hook and return the dispose callback and using console log I can see the component unmounts so it should be getting called.

I also tried calling dispose immedietly. refetch({}).dispose() and that didn't work either.

I am using Relay 15.

Any pointers please?

sho-pb commented 1 year ago

I would like to know how to solve this problem. I am unable to abort when a user hits a series of buttons.

stan2fp commented 1 month ago

I have the same problem. @horne3754sg @sho-pb Did you guys figured it out?