Replies: 1 comment
-
if this isn't working it's likely a react limitation. This error isn't coming from react-query, but from react itself. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a long process running in the
queryFn
function from auseSuspenseQuery
, and I would like to update a context during this process. Thus, I can provide a granular feedback to the user.As an attempt to make it, I wrote a (simplified) code as the following:
But it isn't working as expected.
It returns the error that I wrote in the question title:
Since we can call
setState
within thequeryFn
fromuseQuery
I expected that we could do the usinguseSuspenseQuery
- but it isn't working, and I would like to use suspense for this hook.How to solve this issue?
My main goal is to provide feedback during the long process, and I can't break it into smaller
useSuspenseQuery
s because I have an arbitrary number of tasks that would be hard to express into smaller hooks (it isn't only 2 as the above code).I know that it can be "fixed" by wrapping the
dispatchProgress
call intorequestAnimationFrame(() => { ... })
but I would like to avoid this workaround.Beta Was this translation helpful? Give feedback.
All reactions