useQuery enabled depending on login state
Hi, I need to prevent useQuery from executing when the user isn't logged in. However, this requires me to include
{enabled: isLoggedIn}
in nearly all of my queries. I'm considering doing something like this:
Because this could potentially result in significant alterations to my codebase, I would like to seek your input before proceeding with it.
Thank you ❤️Solution:Jump to solution
That could be a solution. Are there any components or pages that do some action that only logged in users should see, then you could check if user is logged in and only render depending on that, that way you do not have to check if logged in on
useQuery
4 Replies
Solution
That could be a solution. Are there any components or pages that do some action that only logged in users should see, then you could check if user is logged in and only render depending on that, that way you do not have to check if logged in on
useQuery
And make sure the server checks auth
That's an excellent idea! I believe I can restrict certain queries by controlling the rendering of specific components. However, there are some background processes invoked directly within the App XD. It's possible that I may still need to implement the solution mentioned earlier for certain queries. Thanks for your response!
Oh, okay. Yeah for those that is a good solution
If it helped please mark my solution to help others 🙂