TanStackT
TanStack14mo ago
6 replies
dual-salmon

Async Req for Context

Hey when setting up my app, I want to query the server to see if the user is logged in (redirect to login-in page if not)

Is there a better way to do this than having the loading state?

export const App = () => {
  const { data: user, isLoading } = useGetUserQuery();
  if (isLoading) return <div>Loading...</div>;
  return <RouterProvider router={router} context={{ user }} />;
};
Was this page helpful?