fix: include payload in TPA query key to prevent stale cache
The query key only included pageId, so if the payload (tpa_hint, query params, etc.) changed while pageId stayed the same, React Query would serve stale cached data. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Adolfo R. Brandes
parent
bb3ab6cba4
commit
e52d3d89fd
@@ -7,7 +7,7 @@ import { ThirdPartyAuthQueryKeys } from './queryKeys';
|
||||
export const THIRD_PARTY_AUTH_ERROR = 'third-party-auth-error';
|
||||
|
||||
const useThirdPartyAuthHook = (pageId, payload) => useQuery({
|
||||
queryKey: ThirdPartyAuthQueryKeys.byPage(pageId),
|
||||
queryKey: ThirdPartyAuthQueryKeys.byPage(pageId, payload),
|
||||
queryFn: () => getThirdPartyAuthContext(payload),
|
||||
retry: false,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes — TPA context is effectively static per session
|
||||
|
||||
@@ -2,5 +2,5 @@ import { appId } from '../../constants';
|
||||
|
||||
export const ThirdPartyAuthQueryKeys = {
|
||||
all: [appId, 'ThirdPartyAuth'] as const,
|
||||
byPage: (pageId: string) => [appId, 'ThirdPartyAuth', pageId] as const,
|
||||
byPage: (pageId: string, payload?: unknown) => [appId, 'ThirdPartyAuth', pageId, payload] as const,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user