Problem
useIdTokenResult constructs its observable source eagerly:
const observable$ = from(user.getIdTokenResult(forceRefresh));
from(promise) is called at hook-render time, so every re-render that doesn't hit the observable cache fires a discarded getIdTokenResult network request. This is the same pattern fixed in useStorageDownloadURL by #735.
Fix
Wrap in defer() so the promise is constructed at subscription time, not render time:
const observable$ = defer(() => user.getIdTokenResult(forceRefresh));
Related
Problem
useIdTokenResultconstructs its observable source eagerly:from(promise)is called at hook-render time, so every re-render that doesn't hit the observable cache fires a discardedgetIdTokenResultnetwork request. This is the same pattern fixed inuseStorageDownloadURLby #735.Fix
Wrap in
defer()so the promise is constructed at subscription time, not render time:Related
useStorageDownloadURLuseCallableFunctionResponsehas a more severe variant (see useCallableFunctionResponse invokes the cloud function on every re-render #744)