T
TanStack15mo ago
stormy-gold

I have the ID in the function, but I can't call useQuery inside a function? What is the correct way

Hi, could any angel help me structure this solution, I'm using a multi-try application, when I click on a new company, I'm calling handleClick, I need to remove all the queriesKey from the old company, but I'm having trouble when searching for the new ones data, I can't do this outside the react component, esotu providing a code snippet
No description
4 Replies
eastern-cyan
eastern-cyan15mo ago
Please show us the keyFactory.clinic implementation and the error itself. What does it state?
stormy-gold
stormy-goldOP15mo ago
It is stating that I am passing the clinicID to my manufacture, it is saying that at this moment it may be null, I would like to call the function inside handleClick, because there I have the valid clinicID, but it is not possible to use useQuery inside the function , I would like an idea on how to do it correctly, can I use useMutation to fetch the clinic data, and manipulate the data after onSuccess?
eastern-cyan
eastern-cyan15mo ago
React Query and TypeScript
Combine two of the most powerful tools for React Apps to produce great user experience, developer experience and type safety.
React Query Data Transformations
Learn the possibilities to perform the quite common and important task of transforming your data with react-query
eastern-cyan
eastern-cyan15mo ago
Read these two articles. They have answers to your questions and code examples

Did you find this page helpful?