@@ -175,11 +175,12 @@ export function createProductHooks<
175175 input : TListInput & ProductInfiniteInputBase
176176 ) : UseInfiniteProductsResult < TProduct > {
177177 const region = resolveRegion ? resolveRegion ( ) : null
178- const baseInput = { ...input } as TListInput & { enabled ?: boolean }
179- delete baseInput . enabled
180- const resolvedInput = applyRegion ( baseInput , region ?? undefined )
178+ const { enabled : inputEnabled , ...baseInput } = input as TListInput & {
179+ enabled ?: boolean
180+ }
181+ const resolvedInput = applyRegion ( baseInput as TListInput , region ?? undefined )
181182 const enabled =
182- input . enabled ?? ( ! requireRegion || Boolean ( resolvedInput . region_id ) )
183+ inputEnabled ?? ( ! requireRegion || Boolean ( resolvedInput . region_id ) )
183184
184185 const limitFromInput = ( resolvedInput as { limit ?: number } ) . limit
185186 const resolvedLimit =
@@ -354,6 +355,14 @@ export function createProductHooks<
354355 const timeoutsRef = useRef < Map < string , ReturnType < typeof setTimeout > > > (
355356 new Map ( )
356357 )
358+ useEffect ( ( ) => {
359+ return ( ) => {
360+ for ( const timeout of timeoutsRef . current . values ( ) ) {
361+ clearTimeout ( timeout )
362+ }
363+ timeoutsRef . current . clear ( )
364+ }
365+ } , [ ] )
357366 const cacheStrategy = options ?. cacheStrategy ?? "semiStatic"
358367 const defaultDelay = options ?. defaultDelay ?? 800
359368 const skipIfCached = options ?. skipIfCached ?? true
@@ -473,6 +482,14 @@ export function createProductHooks<
473482 const timeoutsRef = useRef < Map < string , ReturnType < typeof setTimeout > > > (
474483 new Map ( )
475484 )
485+ useEffect ( ( ) => {
486+ return ( ) => {
487+ for ( const timeout of timeoutsRef . current . values ( ) ) {
488+ clearTimeout ( timeout )
489+ }
490+ timeoutsRef . current . clear ( )
491+ }
492+ } , [ ] )
476493 const cacheStrategy = options ?. cacheStrategy ?? "semiStatic"
477494 const defaultDelay = options ?. defaultDelay ?? 400
478495 const skipIfCached = options ?. skipIfCached ?? true
0 commit comments