Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/solid-query/src/__tests__/useMutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <button disabled={mutation.isPending}>mutate</button>
}

renderWithClient(queryClient, () => <Page />)

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)
Expand Down
2 changes: 1 addition & 1 deletion packages/solid-query/src/useMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export function useMutation<
let activeMutation: Mutation<TData, TError, TVariables> | 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) {
Expand Down
Loading