query
query copied to clipboard
feat: determine whehter suspend by user
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit dc424d868ab1db0fc093e985cd1316be336da7c9:
Sandbox | Source |
---|---|
@tanstack/query-example-react-basic | Configuration |
@tanstack/query-example-react-basic-typescript | Configuration |
Unfortunately with () => true
as suspense
it goes into infinite fetch loop
Reproduction link -> https://codesandbox.io/s/heuristic-neumann-ohjy5e
@kamilkazmierczakMtab I think it is no problem. cuz it is different between () => true
with true
for suspense
. if set suspense
as function
that it means that this function
should have a boundary conditions to return true
I see, I thought along with @TkDodo that it can allow to force Suspense to be triggered on non-initial fetches e.g. by calling invalidateQueries
like in attempt to do it in my previous example in codesandbox
@kamilkazmierczakMtab But this is what i wanted. I wanna force Suspense
whenever i want. I'm still do not understand what u worry about, cuz it's completely control by developer.
I wanna force Suspense whenever i want.
I think you can get the same behaviour with queryClient.resetQueries
actually. reset
will clear the data from the cache, and then re-render your component. At that point, it will see that there is no data, go fetch it and suspend. I think this would be the better solution to the problem you're trying to solve, wouldn't it ?
given that we have resetQueries
that can likely do exactly what we want, I don't think I'm going to merge this. Also, there is some talk on twitter about a new suspense api coming, and it might be a hook, so calling suspense conditionally might make it more difficult to adapt.
okay😂