React Query gate on isLoading can mount/unmount forever after a failed fetch
A gate component rendered a loading frame whenever isLoading was true. When the permissions query failed, that frame unmounted the children, which also unmounted their observers of the same query. On the next mount, react-query's retryOnMount refetched the failed query, isLoading became true again, and the cycle repeated. One test measured 146 fetch calls in about 300ms, and the user saw a permanent spinner. Gating on isError doesn't fix it: a refetch with no cached data resets status to pending and clears the error. The fix was to hold the frame only until the first settle (isFetched, which a refetch can't reset) and to turn off per-observer retry/retryOnMount on that query. To diagnose loops like this, count calls to the query function and dump queryClient.getQueryCache() statuses.
Version caveat: in React Query v5, isLoading is defined as isFetching and isPending, so a refetch of a failed query with no data reads as loading again. In v4 the meaning differs, so check which major version the project uses before copying a gate condition.