Skip to content

Commit f4547ab

Browse files
authored
Merge branch 'alpha' into alpha/fix-5538
2 parents 3930efc + 99b21aa commit f4547ab

20 files changed

+137
-152
lines changed

packages/react-query-devtools/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/react-query-devtools",
3-
"version": "5.0.0-alpha.70",
3+
"version": "5.0.0-alpha.71",
44
"description": "Developer tools to interact with and visualize the TanStack/react-query cache",
55
"author": "tannerlinsley",
66
"license": "MIT",

packages/react-query-persist-client/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/react-query-persist-client",
3-
"version": "5.0.0-alpha.70",
3+
"version": "5.0.0-alpha.71",
44
"description": "React bindings to work with persisters in TanStack/react-query",
55
"author": "tannerlinsley",
66
"license": "MIT",
@@ -40,8 +40,7 @@
4040
"build:types": "tsc --emitDeclarationOnly"
4141
},
4242
"dependencies": {
43-
"@tanstack/query-persist-client-core": "workspace:*",
44-
"client-only": "0.0.1"
43+
"@tanstack/query-persist-client-core": "workspace:*"
4544
},
4645
"devDependencies": {
4746
"@tanstack/react-query": "workspace:*",

packages/react-query-persist-client/src/PersistQueryClientProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import * as React from 'react'
33

44
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'

packages/react-query/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/react-query",
3-
"version": "5.0.0-alpha.70",
3+
"version": "5.0.0-alpha.71",
44
"description": "Hooks for managing, caching and syncing asynchronous and remote data in React",
55
"author": "tannerlinsley",
66
"license": "MIT",

packages/react-query/src/QueryClientProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import * as React from 'react'
33

44
import type { QueryClient } from '@tanstack/query-core'

packages/react-query/src/useBaseQuery.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import * as React from 'react'
33

44
import type { QueryClient, QueryKey, QueryObserver } from '@tanstack/query-core'

packages/react-query/src/useInfiniteQuery.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import type {
33
QueryObserver,
44
QueryKey,

packages/react-query/src/useIsFetching.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import * as React from 'react'
33
import type { QueryClient, QueryFilters } from '@tanstack/query-core'
44
import { notifyManager } from '@tanstack/query-core'

packages/react-query/src/useMutation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import * as React from 'react'
33
import type { QueryClient, DefaultError } from '@tanstack/query-core'
44
import { notifyManager, MutationObserver } from '@tanstack/query-core'

packages/react-query/src/useMutationState.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import * as React from 'react'
33

44
import type {

packages/react-query/src/useQueries.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import * as React from 'react'
33

44
import type {

packages/react-query/src/useQuery.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'client-only'
1+
'use client'
22
import type { QueryClient, QueryKey, DefaultError } from '@tanstack/query-core'
33
import { QueryObserver } from '@tanstack/query-core'
44
import type {

packages/vue-query/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tanstack/vue-query",
3-
"version": "5.0.0-alpha.70",
3+
"version": "5.0.0-alpha.71",
44
"description": "Hooks for managing, caching and syncing asynchronous and remote data in Vue",
55
"author": "Damian Osipiuk",
66
"license": "MIT",

packages/vue-query/src/useBaseQuery.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import type {
1414
QueryObserverResult,
1515
DefaultedQueryObserverOptions,
1616
} from '@tanstack/query-core'
17-
import { isServer } from '@tanstack/query-core'
1817
import { useQueryClient } from './useQueryClient'
19-
import { updateState, cloneDeepUnref, noop } from './utils'
18+
import { updateState, cloneDeepUnref } from './utils'
2019
import type { QueryClient } from './queryClient'
2120
import type { UseQueryOptions } from './useQuery'
2221
import type { UseInfiniteQueryOptions } from './useInfiniteQuery'
@@ -87,20 +86,19 @@ export function useBaseQuery<
8786
const observer = new Observer(client, defaultedOptions.value)
8887
const state = reactive(observer.getCurrentResult())
8988

90-
const unsubscribe = ref(noop)
89+
const unsubscribe = ref(() => {
90+
// noop
91+
})
9192

9293
watch(
9394
client.isRestoring,
9495
(isRestoring) => {
9596
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
9697
if (!isRestoring) {
9798
unsubscribe.value()
98-
// Nuxt2 memory leak fix - do not subscribe on server
99-
if (!isServer) {
100-
unsubscribe.value = observer.subscribe((result) => {
101-
updateState(state, result)
102-
})
103-
}
99+
unsubscribe.value = observer.subscribe((result) => {
100+
updateState(state, result)
101+
})
104102
}
105103
},
106104
{ immediate: true },
@@ -121,7 +119,9 @@ export function useBaseQuery<
121119

122120
const suspense = () => {
123121
return new Promise<QueryObserverResult<TData, TError>>((resolve) => {
124-
let stopWatch = noop
122+
let stopWatch = () => {
123+
//noop
124+
}
125125
const run = () => {
126126
if (defaultedOptions.value.enabled !== false) {
127127
const optimisticResult = observer.getOptimisticResult(

packages/vue-query/src/useIsFetching.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { computed, onScopeDispose, ref, watch } from 'vue-demi'
22
import type { Ref } from 'vue-demi'
33
import type { QueryFilters as QF } from '@tanstack/query-core'
4-
import { isServer } from '@tanstack/query-core'
54
import { useQueryClient } from './useQueryClient'
6-
import { cloneDeepUnref, noop } from './utils'
5+
import { cloneDeepUnref } from './utils'
76
import type { MaybeRefDeep } from './types'
87
import type { QueryClient } from './queryClient'
98

@@ -18,12 +17,9 @@ export function useIsFetching(
1817

1918
const isFetching = ref(client.isFetching(filters))
2019

21-
// Nuxt2 memory leak fix - do not subscribe on server
22-
const unsubscribe = isServer
23-
? noop
24-
: client.getQueryCache().subscribe(() => {
25-
isFetching.value = client.isFetching(filters)
26-
})
20+
const unsubscribe = client.getQueryCache().subscribe(() => {
21+
isFetching.value = client.isFetching(filters)
22+
})
2723

2824
watch(
2925
filters,

packages/vue-query/src/useMutation.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ import type {
1414
MutationObserverOptions,
1515
DefaultError,
1616
} from '@tanstack/query-core'
17-
import { isServer } from '@tanstack/query-core'
1817
import type { MaybeRefDeep, DistributiveOmit } from './types'
1918
import { MutationObserver } from '@tanstack/query-core'
20-
import { cloneDeepUnref, updateState, noop } from './utils'
19+
import { cloneDeepUnref, updateState } from './utils'
2120
import { useQueryClient } from './useQueryClient'
2221
import type { QueryClient } from './queryClient'
2322

@@ -72,12 +71,9 @@ export function useMutation<
7271
const observer = new MutationObserver(client, options.value)
7372
const state = reactive(observer.getCurrentResult())
7473

75-
// Nuxt2 memory leak fix - do not subscribe on server
76-
const unsubscribe = isServer
77-
? noop
78-
: observer.subscribe((result) => {
79-
updateState(state, result)
80-
})
74+
const unsubscribe = observer.subscribe((result) => {
75+
updateState(state, result)
76+
})
8177

8278
const mutate = (
8379
variables: TVariables,

packages/vue-query/src/useQueries.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2-
import { isServer, QueriesObserver } from '@tanstack/query-core'
2+
import { QueriesObserver } from '@tanstack/query-core'
33
import type {
44
QueriesPlaceholderDataFunction,
55
QueryKey,
@@ -11,7 +11,7 @@ import type { Ref } from 'vue-demi'
1111
import { computed, onScopeDispose, readonly, ref, watch } from 'vue-demi'
1212

1313
import { useQueryClient } from './useQueryClient'
14-
import { cloneDeepUnref, noop } from './utils'
14+
import { cloneDeepUnref } from './utils'
1515
import type { UseQueryOptions } from './useQuery'
1616
import type { QueryClient } from './queryClient'
1717
import type { DistributiveOmit, MaybeRefDeep } from './types'
@@ -182,22 +182,21 @@ export function useQueries<
182182
)
183183
const state = ref(getCombinedResult()) as Ref<TCombinedResult>
184184

185-
const unsubscribe = ref(noop)
185+
const unsubscribe = ref(() => {
186+
// noop
187+
})
186188

187189
watch(
188190
client.isRestoring,
189191
(isRestoring) => {
190192
if (!isRestoring) {
191193
unsubscribe.value()
192-
// Nuxt2 memory leak fix - do not subscribe on server
193-
if (!isServer) {
194-
unsubscribe.value = observer.subscribe(() => {
195-
const [, getCombinedResultRestoring] = observer.getOptimisticResult(
196-
defaultedQueries.value,
197-
)
198-
state.value = getCombinedResultRestoring()
199-
})
200-
}
194+
unsubscribe.value = observer.subscribe(() => {
195+
const [, getCombinedResultRestoring] = observer.getOptimisticResult(
196+
defaultedQueries.value,
197+
)
198+
state.value = getCombinedResultRestoring()
199+
})
201200
// Subscription would not fire for persisted results
202201
const [, getCombinedResultPersisted] = observer.getOptimisticResult(
203202
defaultedQueries.value,

packages/vue-query/src/utils.ts

-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,3 @@ function isPlainObject(value: unknown): value is Object {
6565
const prototype = Object.getPrototypeOf(value)
6666
return prototype === null || prototype === Object.prototype
6767
}
68-
69-
export function noop(): void {
70-
return undefined
71-
}

packages/vue-query/src/vueQueryPlugin.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { isServer } from '@tanstack/query-core'
33
import type { QueryClientConfig } from '@tanstack/query-core'
44

55
import { QueryClient } from './queryClient'
6-
import { getClientKey, noop } from './utils'
6+
import { getClientKey } from './utils'
77
import { setupDevtools } from './devtools/devtools'
88
import type { MaybeRefDeep } from './types'
99

@@ -41,7 +41,9 @@ export const VueQueryPlugin = {
4141
client.mount()
4242
}
4343

44-
let persisterUnmount = noop
44+
let persisterUnmount = () => {
45+
// noop
46+
}
4547

4648
if (options.clientPersister) {
4749
client.isRestoring.value = true

0 commit comments

Comments
 (0)