From 6319052cc1e1126602511da3c0cd3bd2bf1b19ad Mon Sep 17 00:00:00 2001 From: Amiram_se Date: Sat, 10 Oct 2026 23:50:33 +0400 Subject: [PATCH] chore: update --- .../market/src/app/app-shell/hooks/use-slow-reads.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platforms/market/src/app/app-shell/hooks/use-slow-reads.ts b/platforms/market/src/app/app-shell/hooks/use-slow-reads.ts index 95048c5..fc78ff8 100644 --- a/platforms/market/src/app/app-shell/hooks/use-slow-reads.ts +++ b/platforms/market/src/app/app-shell/hooks/use-slow-reads.ts @@ -1,6 +1,6 @@ 'use client'; -import type { QueryClient } from '@tanstack/react-query'; +import { notifyManager, type QueryClient } from '@tanstack/react-query'; import { useEffect, useState } from 'react'; import { SLOW_READ_MS } from '../constants'; @@ -18,6 +18,7 @@ export function useSlowReads(queryClient: QueryClient): boolean { // When each first read still loading started, by query. const started = new Map(); let timer: ReturnType | undefined; + let active = true; const check = () => { clearTimeout(timer); @@ -43,9 +44,16 @@ export function useSlowReads(queryClient: QueryClient): boolean { if (wait > 0) timer = setTimeout(check, wait); }; - const unsubscribe = cache.subscribe(check); + // The cache notifies while a child's useQuery builds its query mid-render; defer so this + // component's setState never lands inside another component's render. + const unsubscribe = cache.subscribe(() => + notifyManager.schedule(() => { + if (active) check(); + }), + ); check(); return () => { + active = false; unsubscribe(); clearTimeout(timer); };