Does ReactDom's flushSync works with setQueryData in same way as it works with setState()?
In reference to this example in react docs(https://react.dev/learn/manipulating-the-dom-with-refs#flushing-state-updates-synchronously-with-flush-sync) where
flushSync
API from React DOM can be used to sync DOM to state updates synchronously, Can we wrap setQueryData
call for a active
query in flushSync
callback and expect to access the updated DOM for scrolling etc?
I tried and it doesnt work. If it does not, what is the alternative?Manipulating the DOM with Refs – React
The library for web and native user interfaces
6 Replies
xenial-blackOP•2y ago
@M00LTi , @TkDodo 🔮 , can you please help me out here?
other-emerald•2y ago
are you doing this with a
useMutation
?
i guess you should do the queryClient update inside the onSuccess
of useMutation and the scrolling in the onSuccess
of mutatexenial-blackOP•2y ago
Yes @M00LTi , I am doing it inside the onSuccess callback of a useMutation hook.
other-emerald•2y ago
So did you follow my instructions?
xenial-blackOP•2y ago
Yes, I have the exact same setup as you explained
other-emerald•2y ago
Show it