#How to access mutationState in v4? What is the pattern to work on project with many mutations?

10 messages · Page 1 of 1 (latest)

tulip fog
#

I have a project where my entities have many states. State is changed by post requests. I have many post requests, that return current state or error of entity.
I would like to have access to the data of post request in another component. So now i just setQueryData in onSuccess and onError. Is this right?

solar comet
#

Yeah that’s nice

tulip fog
#

setQueryData is not updating state of another component.
I do:
onSuccess: (data) => {
queryClient.setQueryData(
[QUERY_KEY_REGISTERED_INVOICE, {barcode: data?.barcode}],
data,
);
},

but in another component getQueryData is not called again

#

I dont have GET method. So i just want to get updated data by key and rerender component, is it possible?

#

ok, that somehow works without fetchFn

tulip fog
#

I get errors in console: " Missing queryFn for queryKey '["registeredInvoice",{"barcode":"1110339131184383"}] "

But i still get data and evrth works. Can i work with it?

tulip fog
#

anyone?

solar comet
#

Yea, provide some queryFn and set enabled: false

tulip fog