@@ -31,11 +31,13 @@ import {
3131 InfiniteQueryFlattenConfig ,
3232 InfiniteQueryInvalidateParams ,
3333 InfiniteQueryOptions ,
34+ InfiniteQueryRemoveParams ,
3435 InfiniteQueryResetParams ,
3536 InfiniteQueryStartParams ,
3637 InfiniteQueryUpdateOptionsAllVariants ,
3738} from './inifinite-query.types' ;
3839import { Query } from './query' ;
40+ import { QueryClient } from './query-client' ;
3941import { AnyQueryClient , QueryClientHooks } from './query-client.types' ;
4042import { QueryFeatures } from './query.types' ;
4143
@@ -581,6 +583,10 @@ export class InfiniteQuery<
581583 return await Query . prototype . reset . call ( this , params ) ;
582584 }
583585
586+ remove ( params ?: InfiniteQueryRemoveParams ) {
587+ return Query . prototype . remove . call ( this , params ) ;
588+ }
589+
584590 async invalidate ( options ?: InfiniteQueryInvalidateParams ) {
585591 return await Query . prototype . invalidate . call ( this , options ) ;
586592 }
@@ -616,17 +622,28 @@ export class InfiniteQuery<
616622
617623 let isNeedToReset =
618624 this . config . resetOnDestroy || this . config . resetOnDispose ;
625+ let isNeedToRemove = this . config . removeOnDestroy ;
626+
627+ if ( this . queryClient instanceof QueryClient ) {
628+ if ( isNeedToReset === undefined ) {
629+ isNeedToReset =
630+ this . queryClient . queryFeatures . resetOnDestroy ||
631+ this . queryClient . queryFeatures . resetOnDispose ;
632+ }
619633
620- if ( 'queryFeatures' in this . queryClient && ! isNeedToReset ) {
621- isNeedToReset =
622- this . queryClient . queryFeatures . resetOnDestroy ||
623- this . queryClient . queryFeatures . resetOnDispose ;
634+ if ( isNeedToRemove === undefined ) {
635+ isNeedToRemove = this . queryClient . queryFeatures . removeOnDestroy ;
636+ }
624637 }
625638
626639 if ( isNeedToReset ) {
627640 this . reset ( ) ;
628641 }
629642
643+ if ( isNeedToRemove ) {
644+ this . remove ( ) ;
645+ }
646+
630647 delete this . _observerSubscription ;
631648 this . hooks ?. onInfiniteQueryDestroy ?.( this ) ;
632649 }
0 commit comments