Clarification of the behaviour of refetchOnMountOrArgChange
#3654
dwjohnston
started this conversation in
General
Replies: 1 comment 1 reply
-
It does look like that's the case. Here's the args serialisation function: Is this a potential problematic performance issue, if we had large args objects that happened to be going through as args, and they'd be doing that sort and stringify every render? (But FWIF, at this point I'm not griping at all - one of my biggest bug bears with React is how the declaration of new objects will trip shallow equality checking and cause all sorts of issues for me, so that this doesn't, is quite a relief for me). |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The
refetchOnMountOrArgChange
option is helpful for me, where when a component remounts I want the data the refetched regardless of what's already in the cache.However, I was worried that if I had something like:
Then you would get a 'refetch every render' problem - because a new object is declared every time this component/hook renders.
However, this doesn't seem to be a problem.
I've a repro of this here, it's a modification of the Kitchen Sink example.
https://codesandbox.io/s/lucid-haze-qqntsp?file=/src/features/posts/PostDetail.tsx:1779-1963
I'm wondering how is this behaviour achieved? Is RTKQ stringifying the object to check for deep equality?
Beta Was this translation helpful? Give feedback.
All reactions