-
I made a custom hook using useQuery so my components can determine if the user is authenticated:
I attached an error handler to every API call that checks to see if the status code is 401, which would imply I am no longer authenticated. When that happens, I clear out my user session and invalidate the
One place I am using is in the
I would expect this to work, of course. But instead when I have no hooks defined after that check, so I don't understand why I am getting this error. It leads me to believe it could have something to do with when I am invalidating the query. Are there rules about when I can call |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Here's a stack trace from one of the exceptions:
|
Beta Was this translation helpful? Give feedback.
-
This turned out to be caused by a seemingly unrelated component, where i was passing in a function that used useQuery (not part of a component). Makes me wonder if there's a way to root out places where we are violating the rules of hooks... |
Beta Was this translation helpful? Give feedback.
This turned out to be caused by a seemingly unrelated component, where i was passing in a function that used useQuery (not part of a component).
Makes me wonder if there's a way to root out places where we are violating the rules of hooks...