Skip to content
Open
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
7 changes: 7 additions & 0 deletions .changeset/preact-v11-peer-dependency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@tanstack/preact-query': patch
'@tanstack/preact-query-devtools': patch
'@tanstack/preact-query-persist-client': patch
---

Add Preact v11 to peerDependencies
2 changes: 1 addition & 1 deletion packages/preact-query-devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@
},
"peerDependencies": {
"@tanstack/preact-query": "workspace:^",
"preact": "^10.0.0"
"preact": "^10.0.0 || ^11.0.0-0"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { render } from '@testing-library/preact'
import { act, render } from '@testing-library/preact'
import { QueryClient, QueryClientProvider } from '@tanstack/preact-query'
import { TanstackQueryDevtools } from '@tanstack/query-devtools'
import type { PreactQueryDevtools as PreactQueryDevtoolsComponent } from '../PreactQueryDevtools'
Expand Down Expand Up @@ -216,7 +216,9 @@ describe('PreactQueryDevtools', () => {

it('should call "unmount" on the devtools instance when the component unmounts', () => {
const { unmount } = render(<PreactQueryDevtools client={queryClient} />)
unmount()
act(() => {
unmount()
})

expect(unmountMock).toHaveBeenCalled()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { render } from '@testing-library/preact'
import { act, render } from '@testing-library/preact'
import { QueryClient, QueryClientProvider } from '@tanstack/preact-query'
import { TanstackQueryDevtoolsPanel } from '@tanstack/query-devtools'
import type { PreactQueryDevtoolsPanel as PreactQueryDevtoolsPanelComponent } from '../PreactQueryDevtoolsPanel'
Expand Down Expand Up @@ -175,7 +175,9 @@ describe('PreactQueryDevtoolsPanel', () => {
const { unmount } = render(
<PreactQueryDevtoolsPanel client={queryClient} />,
)
unmount()
act(() => {
unmount()
})

expect(unmountMock).toHaveBeenCalled()
})
Expand Down
5 changes: 4 additions & 1 deletion packages/preact-query-devtools/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { notifyManager } from '@tanstack/preact-query'
import { afterEach } from 'vitest'

// https://testing-library.com/docs/preact-testing-library/api#cleanup
// Wrap in act so effect cleanups Preact defers on unmount run synchronously
afterEach(() => {
cleanupRTL()
act(() => {
cleanupRTL()
})
})

// Wrap notifications with act to make sure Preact knows about Query updates
Expand Down
2 changes: 1 addition & 1 deletion packages/preact-query-persist-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@
},
"peerDependencies": {
"@tanstack/preact-query": "workspace:^",
"preact": "^10.0.0"
"preact": "^10.0.0 || ^11.0.0-0"
}
}
5 changes: 4 additions & 1 deletion packages/preact-query-persist-client/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { afterEach } from 'vitest'
import { notifyManager } from '@tanstack/preact-query'

// https://testing-library.com/docs/preact-testing-library/api#cleanup
// Wrap in act so effect cleanups Preact defers on unmount run synchronously
afterEach(() => {
cleanupRTL()
act(() => {
cleanupRTL()
})
})

// Wrap notifications with act to make sure Preact knows about Query updates
Expand Down
2 changes: 1 addition & 1 deletion packages/preact-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@
"typescript-eslint": "^8.54.0"
},
"peerDependencies": {
"preact": "^10.0.0"
"preact": "^10.0.0 || ^11.0.0-0"
}
}
8 changes: 6 additions & 2 deletions packages/preact-query/src/__tests__/useQuery.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3966,7 +3966,9 @@ describe('useQuery', () => {
rendered.getByText('fetched data')
const setTimeoutSpy = vi.spyOn(globalThis.window, 'setTimeout')

rendered.unmount()
act(() => {
rendered.unmount()
})

expect(setTimeoutSpy).not.toHaveBeenCalled()
})
Expand All @@ -3990,7 +3992,9 @@ describe('useQuery', () => {

const setTimeoutSpy = vi.spyOn(globalThis.window, 'setTimeout')

rendered.unmount()
act(() => {
rendered.unmount()
})

expect(setTimeoutSpy).toHaveBeenLastCalledWith(
expect.any(Function),
Expand Down
2 changes: 1 addition & 1 deletion packages/preact-query/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function useSyncExternalStoreWithSelector<TSnapshot, TSelected>(
selector: (snapshot: TSnapshot) => TSelected,
isEqual: (a: TSelected, b: TSelected) => boolean,
): TSelected {
const selectedSnapshotRef = useRef<TSelected | undefined>()
const selectedSnapshotRef = useRef<TSelected | undefined>(undefined)

const getSelectedSnapshot = () => {
const snapshot = getSnapshot()
Expand Down
5 changes: 4 additions & 1 deletion packages/preact-query/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { act, cleanup as cleanupRTL } from '@testing-library/preact'
import { afterEach } from 'vitest'

// https://testing-library.com/docs/preact-testing-library/api#cleanup
// Wrap in act so effect cleanups Preact defers on unmount run synchronously
afterEach(() => {
cleanupRTL()
act(() => {
cleanupRTL()
})
})

// Wrap notifications with act to make sure React knows about React Query updates
Expand Down