Component evidence

src/useMutation.ts

query · packages/react-query/src/useMutation.ts · typescript · MIT
ui

React hook for performing mutations with optimistic updates, error handling, and query invalidation.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/TanStack/query | License: MIT | Copyright 2021-present Tanner Linsley
// Provided via justclaw.it.com; keep this notice with the code.
'use client'
import * as React from 'react'
import {
  MutationObserver,
  noop,
  notifyManager,
  shouldThrowError,
} from '@tanstack/query-core'
import { useQueryClient } from './QueryClientProvider'
import type {
  UseMutateFunction,
  UseMutationOptions,
  UseMutationResult,
} from './types'
import type { DefaultError, QueryClient } from '@tanstack/query-core'

// HOOK

/**
 * Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects.
 * `useMutation` is the hook for that.
 * @param options - The {@link UseMutationOptions} to use — everything you can pass to `useMutation`.
 * 

... (truncated -- full source via MCP)