Skip to content
Discussion options

You must be logged in to vote

you'd want to create the client and the cache only once, but you can do this:

  const { authorize } = useAuth0();

  const queryClient = useState(() => new QueryClient()

  useEffect(() => {
    queryClient.getQueryCache().config.onError = (error) => {
      // Check for 401 and redirect here
      if (error.response?.status === 401) {
        authorize()
      }
    }
  }, [authorize])

of course, if authorize is referentially stable, you can just put everything into useState. But if its not you might get stale closure issues.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@alisasila
Comment options

@eric-tiew93
Comment options

Answer selected by alisasila
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants