Skip to content

Commit

Permalink
Fix cleanup hook issues
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jan 5, 2025
1 parent 249e0ec commit f93bec9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/toolkit/src/query/react/buildHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ import { useStableQueryArgs } from './useSerializedStableValue'
import { useShallowStableValue } from './useShallowStableValue'
import type { InfiniteQueryDirection } from '../core/apiState'
import { isInfiniteQueryDefinition } from '../endpointDefinitions'
import {
StartInfiniteQueryActionCreatorOptions,
StartInfiniteQueryActionCreator,
} from '../core/buildInitiate'
import { StartInfiniteQueryActionCreator } from '../core/buildInitiate'

// Copy-pasted from React-Redux
const canUseDOM = () =>
Expand Down Expand Up @@ -1647,7 +1644,8 @@ export function buildHooks<Definitions extends EndpointDefinitions>({
useEffect(() => {
return () => {
promiseRef.current?.unsubscribe?.()
promiseRef.current = undefined
// eslint-disable-next-line react-hooks/exhaustive-deps
;(promiseRef.current as any) = undefined
}
}, [promiseRef])
}
Expand Down

0 comments on commit f93bec9

Please sign in to comment.