Skip to content

Commit dcd4e58

Browse files
committed
Use shallowReadonly and shallowRef in useMutationState too
1 parent 5710b3d commit dcd4e58

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/vue-query/src/useMutationState.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import {
22
computed,
33
getCurrentScope,
44
onScopeDispose,
5-
readonly,
6-
ref,
5+
shallowReadonly,
6+
shallowRef,
77
watch,
88
} from 'vue-demi'
99
import { useQueryClient } from './useQueryClient'
1010
import { cloneDeepUnref } from './utils'
11-
import type { DeepReadonly, Ref } from 'vue-demi'
11+
import type { Ref } from 'vue-demi'
1212
import type {
1313
MutationFilters as MF,
1414
Mutation,
@@ -68,10 +68,12 @@ function getResult<TResult = MutationState>(
6868
export function useMutationState<TResult = MutationState>(
6969
options: MutationStateOptions<TResult> = {},
7070
queryClient?: QueryClient,
71-
): DeepReadonly<Ref<Array<TResult>>> {
71+
): Readonly<Ref<Array<TResult>>> {
7272
const filters = computed(() => cloneDeepUnref(options.filters))
7373
const mutationCache = (queryClient || useQueryClient()).getMutationCache()
74-
const state = ref(getResult(mutationCache, options)) as Ref<Array<TResult>>
74+
const state = shallowRef(getResult(mutationCache, options)) as Ref<
75+
Array<TResult>
76+
>
7577
const unsubscribe = mutationCache.subscribe(() => {
7678
const result = getResult(mutationCache, options)
7779
state.value = result
@@ -85,5 +87,5 @@ export function useMutationState<TResult = MutationState>(
8587
unsubscribe()
8688
})
8789

88-
return readonly(state)
90+
return shallowReadonly(state)
8991
}

0 commit comments

Comments
 (0)