Prevent possibly undefined user with useQuery
I have a hook
Lets imagine that its used in a
Now I want to get the user inside a component nested in
Using
Doesn't seem good because the user is always here if the component rendered.
useUser that looks basically like this Lets imagine that its used in a
Layout so when the user is loading the whole app is just a loading spinner. Now I want to get the user inside a component nested in
LayoutUsing
useUser hook makes no sense here because its return is always User | undefined as typescript doesn't know the user is loaded somewhere higher. How do I solve this problem? Checking Doesn't seem good because the user is always here if the component rendered.
