Skip to content

Commit 5c47711

Browse files
committed
Prevent infinite loop
1 parent f5ad7d3 commit 5c47711

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/solid-query/src/useMutationState.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
1+
import { untrack, createEffect, createMemo, createSignal, onCleanup } from 'solid-js'
22
import { replaceEqualDeep } from '@tanstack/query-core'
33
import { useQueryClient } from './QueryClientProvider'
44
import type {
@@ -40,11 +40,12 @@ export function useMutationState<TResult = MutationState>(
4040

4141
createEffect(() => {
4242
const unsubscribe = mutationCache().subscribe(() => {
43+
const _result = untrack(result)
4344
const nextResult = replaceEqualDeep(
44-
result(),
45+
_result,
4546
getResult(mutationCache(), options()),
4647
)
47-
if (result() !== nextResult) {
48+
if (_result !== nextResult) {
4849
setResult(nextResult)
4950
}
5051
})

0 commit comments

Comments
 (0)