You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And lets say I deselect a single customer (e.g. customer 123), then this query is made:
/customers?driverId=456&driverId=789&...
So another query, and another cache entry with data that all was already fetched.
I've been trying to get this excessive query/caching to be better, but am struggling. I keep thinking there must be a way this is supposed to be done with RTK but I can't find anything!
Any pointers would be very much appreciated!
Some things I've thought of doing but either can't or it's really ugly:
Make a call to /customers?driverId=??? for 1 driver at a time, in a loop, but I can't use the hook inside a loop in the component.
Use the lazyQuery, then I can do it in a loop, but now invalidation doesn't trigger component re-rendering as I'd like.
Create a separate redux slice, bypassing RTK to take care of this logic. (would be fine but just keep thinking RTK would already have a pattern for this type of use case that I should be using)
Use queryFn instead of query in RTK, where I can check the endpoint state. But then handling invalidation is impossible (unless I'm missing something, I don't see any invalidating state in the rtk state)
The text was updated successfully, but these errors were encountered:
Hi folks! I have an RTK question, hope this is the right place to ask it. I've got an RTK endpoint definition that looks something like:
I have a react component that allows you to select/deselect multiple customers. Select/Deselect/Bulk Select/Bulk Deselect.
Its works well with the above RTK definition, using something like this in the component:
The problem is, the caching isn't working well.
E.g. if you select all customers, it makes a query/cache entry for:
And lets say I deselect a single customer (e.g. customer 123), then this query is made:
So another query, and another cache entry with data that all was already fetched.
I've been trying to get this excessive query/caching to be better, but am struggling. I keep thinking there must be a way this is supposed to be done with RTK but I can't find anything!
Any pointers would be very much appreciated!
Some things I've thought of doing but either can't or it's really ugly:
/customers?driverId=???
for 1 driver at a time, in a loop, but I can't use the hook inside a loop in the component.queryFn
instead ofquery
in RTK, where I can check the endpoint state. But then handling invalidation is impossible (unless I'm missing something, I don't see any invalidating state in the rtk state)The text was updated successfully, but these errors were encountered: