TanStackT
TanStack14mo ago
2 replies
dead-brown

Simple question regarding redirecting on error

I have a simple question. Take the following code:

  const { isError } = useQuery(getUserInfo);
  if (isError) {
    return <Navigate to="/signup" />;
  }


This works, but it tries three times so it actually takes a few seconds to redirect to /signup if the user is logged out (401). Can I detect a 401 the first time and redirect right away?
Was this page helpful?