diff --git a/__tests__/atomWithQuery_spec.tsx b/__tests__/atomWithQuery_spec.tsx index 86de580..747d936 100644 --- a/__tests__/atomWithQuery_spec.tsx +++ b/__tests__/atomWithQuery_spec.tsx @@ -645,8 +645,8 @@ describe('error handling', () => { }) }) -// // Test for bug described here: -// // https://github.com/jotaijs/jotai-tanstack-query/issues/34 +// Test for bug described here: +// https://github.com/jotaijs/jotai-tanstack-query/issues/34 // Note: If error handling tests run after this test, they are failing. Not sure why. it('renews the result when the query changes and a non stale cache is available', async () => { const queryClient = new QueryClient({ diff --git a/src/baseAtomWithQuery.ts b/src/baseAtomWithQuery.ts index a6d254e..2aefea8 100644 --- a/src/baseAtomWithQuery.ts +++ b/src/baseAtomWithQuery.ts @@ -90,7 +90,6 @@ export function baseAtomWithQuery< } const dataAtom = atom((get) => { - const client = getQueryClient(get) const observer = get(observerAtom) const defaultedOptions = get(defaultedOptionsAtom) const result = observer.getOptimisticResult(defaultedOptions) @@ -104,7 +103,7 @@ export function baseAtomWithQuery< const unsubscribe = observer.subscribe(notifyManager.batchCalls(set)) return () => { if (observer.getCurrentResult().isError) { - client.resetQueries({ queryKey: observer.getCurrentQuery().queryKey }) + observer.getCurrentQuery().reset() } unsubscribe() }