Replies: 2 comments 3 replies
-
You would use const [userID, setUserID] = useState(null)
// Avoid initiating query until `userID` is populated
const { data, error } = useQuery(
!!userID && ['getUserData', userID],
runQuery,
{
initialData: [],
}
);
function onClick(userID) {
setUserID(userID)
} See https://github.com/tannerlinsley/react-query#dependent-queries Cheers! |
Beta Was this translation helpful? Give feedback.
1 reply
-
What about using It seems I can just call function onClick(userID) {
const data = queryCache.prefetchQuery('getUserData', userID, runQuery);
setUserData(data);
} |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a case where I want to run manual query when for example use clicks a button and pass some parameters to the query function. How can I do this with react-query?
Here is an example:
Beta Was this translation helpful? Give feedback.
All reactions