Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: reset query via query instead of using resetQueries on client #93

Merged
merged 1 commit into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/atomWithQuery_spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
3 changes: 1 addition & 2 deletions src/baseAtomWithQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
}
Expand Down
Loading