diff --git a/packages/solid-query/src/__tests__/useMutation.test.tsx b/packages/solid-query/src/__tests__/useMutation.test.tsx index bfaadc105d..aef4c2e381 100644 --- a/packages/solid-query/src/__tests__/useMutation.test.tsx +++ b/packages/solid-query/src/__tests__/useMutation.test.tsx @@ -105,6 +105,30 @@ describe('useMutation', () => { consoleMock.mockRestore() }) + it('should not emit a strict-read diagnostic on mount', () => { + const consoleMock = vi + .spyOn(console, 'warn') + .mockImplementation(() => undefined) + + function Page() { + const mutation = useMutation(() => ({ + mutationFn: () => Promise.resolve('mutation'), + })) + + return + } + + renderWithClient(queryClient, () => ) + + expect( + consoleMock.mock.calls.filter((args) => + args.some((arg) => String(arg).includes('STRICT_READ_UNTRACKED')), + ), + ).toEqual([]) + + consoleMock.mockRestore() + }) + it('should be able to call `onSuccess` and `onSettled` after each successful mutate', async () => { let countRef = 0 const [count, setCount] = createSignal(0) diff --git a/packages/solid-query/src/useMutation.ts b/packages/solid-query/src/useMutation.ts index 1d0b2f7b5c..903e3120f3 100644 --- a/packages/solid-query/src/useMutation.ts +++ b/packages/solid-query/src/useMutation.ts @@ -119,7 +119,7 @@ export function useMutation< let activeMutation: Mutation | null = null const [flightVersion, setFlightVersion] = createSignal(0) if (!isServer) { - const unsubscribe = client() + const unsubscribe = untrack(client) .getMutationCache() .subscribe((event) => { if ('mutation' in event && event.mutation === activeMutation) {