useMutation Hook triggers rerender of component when a non-related subscription receives new data
Hello, I'm using trpc with hooks from TanStack-Query. I noticed something very strange regarding the useMutation hook:
I have a subscription in one part of my app that receives new data about every third second. Internally, this seems to trigger a rerender for all of my components using any useMutation hook. I noticed this because one of those components is very heavy and creates a stutter whenever new data arrives.
The first picture shows the frequent heavy rerender, the second and third ones show the causing change inside the react profiling-devtools (hook 37 and 40).
These are related to "MutationObserver" and "SyncExternalStore" (picture 4).
I can definitely tell that these mutations are not executed at the peaking times.
Can someone please take a look and help me investigate it further? Thanks in advance



2 Replies
frozen-sapphireOP•2y ago
Forgot fourth image:

frozen-sapphireOP•2y ago
Does this belong in a GitHub issue rather than here?