Skip to content
Source
Sign inSign up
TanStack/query

Select with a transform may break when refetchInterval is set to a function #5309

ClosedNick-Lucas(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/5309/headopened View on GitHub

Showing 1 changed file with 37 additions and 0 deletions.

x
0 of 1 viewed, 1 left
37 additions and 0 deletionspackages/react-query/src/__tests__/useQuery.test.tsxModified
View file
@@ -5887,4 +5887,41 @@
fireEvent.click(fetchBtn)
await waitFor(() => rendered.getByText('data: 3'))
+​
+ it('combines refetchInterval with select', async () => {
+ function Page() {
+ useQuery(
+ ['my-query'],
+ function () {
+ return { foo: 1 }
+ },
+ {
+ refetchInterval(data) {
+ // ^ should not produce a type error
+ return 10000
+ },
+ select(data) {
+ return data.foo
+ },
+ },
+ )
+ useQuery({
+ queryKey: ['my-query'],
+ queryFn() {
+ return { foo: 1 }