Skip to content

Commit 6d128a1

Browse files
committed
fix(vue-query): use shallowReactive and shallowReadonly to prevent perforamcne slowdown for large datasets
1 parent 79e5202 commit 6d128a1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/vue-query/src/useBaseQuery.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {
22
computed,
33
getCurrentScope,
44
onScopeDispose,
5-
reactive,
6-
readonly,
5+
shallowReactive,
6+
shallowReadonly,
77
toRefs,
88
watch,
99
} from 'vue-demi'
@@ -105,7 +105,7 @@ export function useBaseQuery<
105105
})
106106

107107
const observer = new Observer(client, defaultedOptions.value)
108-
const state = reactive(observer.getCurrentResult())
108+
const state = shallowReactive(observer.getCurrentResult())
109109

110110
let unsubscribe = () => {
111111
// noop
@@ -201,7 +201,7 @@ export function useBaseQuery<
201201
},
202202
)
203203

204-
const object: any = toRefs(readonly(state))
204+
const object: any = toRefs(shallowReadonly(state))
205205
for (const key in state) {
206206
if (typeof state[key as keyof typeof state] === 'function') {
207207
object[key] = state[key as keyof typeof state]

packages/vue-query/src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function getClientKey(key?: string) {
99
}
1010

1111
export function updateState(
12-
state: Record<string, unknown>,
12+
state: Record<string, any>,
1313
update: Record<string, any>,
1414
): void {
1515
Object.keys(state).forEach((key) => {

0 commit comments

Comments
 (0)