T
TanStack15mo ago
genetic-orange

I need to invalidate a query from a redux action

Hey folks, I need to invalidate a query from a redux action but when I call const queryClient = useQueryClient(); it does not work (crash the function without any error), do you know what is going on and how can I handle that case? Thank you!
3 Replies
genetic-orange
genetic-orangeOP15mo ago
it's caused by the rool of hooks but I don't know what is the solution to that?
deep-jade
deep-jade15mo ago
As I mentioned you can directly import the queryClient from the module that you created and call it's methods directly. I think focusing on the action is the wrong way to think about this: the action is just an object with the action type and a payload that's fed into the redux reducer. Both action creator functions and reducers should be pure with no side effects

Did you find this page helpful?