Skip to content

Commit 61142a0

Browse files
perf(vue-query): use shallowRef instead of ref in useQueries (#6657)
* perf: use shallowRef * chore: lint * chore: format with prettier --------- Co-authored-by: Damian Osipiuk <[email protected]>
1 parent 58fe2eb commit 61142a0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/vue-query/src/useQueries.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import {
55
getCurrentScope,
66
onScopeDispose,
77
readonly,
8-
ref,
8+
shallowRef,
99
watch,
1010
} from 'vue-demi'
1111

1212
import { useQueryClient } from './useQueryClient'
1313
import { cloneDeepUnref } from './utils'
14-
import type { Ref } from 'vue-demi'
14+
import type { ShallowRef } from 'vue-demi'
1515
import type {
1616
DefaultError,
1717
DefinedQueryObserverResult,
@@ -259,7 +259,7 @@ export function useQueries<
259259
combine?: (result: UseQueriesResults<T>) => TCombinedResult
260260
},
261261
queryClient?: QueryClient,
262-
): Readonly<Ref<TCombinedResult>> {
262+
): Readonly<ShallowRef<TCombinedResult>> {
263263
if (process.env.NODE_ENV === 'development') {
264264
if (!getCurrentScope()) {
265265
console.warn(
@@ -294,7 +294,7 @@ export function useQueries<
294294
defaultedQueries.value,
295295
(options as QueriesObserverOptions<TCombinedResult>).combine,
296296
)
297-
const state = ref(getCombinedResult()) as Ref<TCombinedResult>
297+
const state = shallowRef(getCombinedResult())
298298

299299
let unsubscribe = () => {
300300
// noop
@@ -343,5 +343,5 @@ export function useQueries<
343343
unsubscribe()
344344
})
345345

346-
return readonly(state) as Readonly<Ref<TCombinedResult>>
346+
return readonly(state) as Readonly<ShallowRef<TCombinedResult>>
347347
}

0 commit comments

Comments
 (0)