Pass different parameter to query fn depending on how it is used
Hello all,
I have the following case:
I have a react native app that needs to make a network request the first time the app opens and every time the app comes from background to foreground. It is also invalidated at times throughout the lifetime of the app.
Here is the query:
Here is how I refetch when the app comes from background to foreground:
and throughout the app I invalidate the query according to some requirements:
Here is what I need to do. I need to be able to pass a value to the query that is sent with the request to tell the server why this query was called. Let's say it is an attribute called
purpose and has values of either first open | reopen | invalidating
Basically I need a way to know which one cause the query to run. How can I achieve that?2 Replies
ratty-blush•3y ago
nothing built-in to do this. You can write the reason to a ref / global var / store and read it from the queryFn
xenial-blackOP•3y ago
Alright thanks for the answer!