Replies: 2 comments 2 replies
-
We notify the AbortSignal if the last observer of a query unmounts. It can very well be that with suspense and deferred value, that isn't happening. I don't enough how suspense does this under the hood. I tried to see if the signal is called properly when not using suspense in your example, simply by doing this:
but then the example starts to break. Maybe you can provide an example that doesn't use 3rd party components (mui), has the query devtools enabled and maybe does a real network request so that we can see the aborted requests there? Thanks.
yes, or you move the query into a component further down the component tree that renders conditionally and gets the
yes, if you want them to work on the same cache entry. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help.
I don't think anyone does at the moment.
I updated the demo to remove mui and add devtools. The result is similar, but itt's nice to have the demo simplified. It seems the issue was that the fallback to Suspense was
It's still always ever false with the code change, but I also don't know anything about suspense. I remember seeing a tweet from Sebastian Markbåge saying that useDeferredValue is preferred over debounce here, which is why I wanted to try this out. I'd like to see more suspense examples in the react docs. |
Beta Was this translation helpful? Give feedback.
-
I noticed that my
searchPersons
function never has its abort signal called. Is that expected?Also, I noticed
isFetching
is alwaysfalse
. Should loading be derived fromsearchValue !== autocompleteValue
?If I want
searchPersons
to not hit the backend when my string is empty, do I just customize thesearchPersons
function to return an empty array when the query is an empty string? I see there is noenabled
.Finally, is it ok to use
useSuspenseQuery
forkey1
and thenuseQuery
for the samekey1
?demo
Beta Was this translation helpful? Give feedback.
All reactions