TRPC UseQuery

How can I have a trpc useQuery hook only be called if there is an active logged in session? I understand that you can't use hooks inside conditional statements, and that's why I'm getting the following error.

Unhandled Runtime Error
Error: Rendered more hooks than during the previous render.
Image

If I put the useQuery outside of the if statement, the code works as expected but I'm not sure if that's a good practice to call protected routes when no one is logged in.
Image
image.png
image.png
Was this page helpful?