mutation
A change to data, and in TanStack Query or tRPC specifically, a request that creates, updates or deletes data on the server.
In more detail
Queries only read, while mutations write, so mutations are where caches must be invalidated and CSRF tokens checked. The TanStack Query mutation lifecycle is also the place to apply and roll back optimistic updates.
Examples
React cannot see mutations of state or props, so nothing re-renders; refs are the deliberate exception, a mutable box React does not track.With TanStack Query, a mutation means a request that changes data on the server.props.items.slice().sort() // copy first, then sortRelated terms
- TanStack Query — A library that fetches, caches and refreshes server data in frontend apps, and runs changes to it as mutations.
- cache invalidation — Marking cached copies as out of date, or deleting them, when the real data changes so the next read fetches fresh data.
- optimistic update — Showing the result of a user’s action on screen immediately, before the server confirms it, and undoing it if the server says no.
- cross-site request forgery — An attack where another website makes the victim's browser send a request to your site, and the browser's cookie makes it look genuine.
- immutable — Something that cannot be changed after it is created; to change it you make a new one.
- reference equality — Comparing two references to see whether they point to the very same object, rather than to objects with equal contents.
- toSorted — An array method that returns a sorted copy and leaves the original unchanged, unlike sort, which reorders the array in place.
- useRef — The React hook that creates a ref object, { current: initialValue }, which stays the same object for the life of the component.
Taught in
- Database Access & Migrations: ORM & Data Layers — Production Full-Stack Engineering
- Type-Safe Client Generation: Orval & Automated SDKs — Production Full-Stack Engineering
- Type-Safe RPC Architectures: tRPC & Procedures — Production Full-Stack Engineering
- Session Architecture: HTTP-Only Cookies vs Tokens — Production Full-Stack Engineering
- Optimistic UI Architecture: Cache & Rollback Protocols — Production Full-Stack Engineering
- Component Purity: Pure Functions, Idempotence And Side Effects — React 19 & Modern Component Architecture
- Props Contract: Immutability, Children, And Polymorphic Tags — React 19 & Modern Component Architecture
- State with useState: Immutability And Asynchronous Batching — React 19 & Modern Component Architecture
- Virtual DOM vs Real DOM: The Reconciliation Cost Model — React 19 & Modern Component Architecture
- Keys In Depth: Identity Preservation And Identity Resetting — React 19 & Modern Component Architecture
- Diffing Algorithm: Element Type Shifts And Subtree Tear Down — React 19 & Modern Component Architecture
- useLayoutEffect vs useEffect: Painting And Synchronous Reads — React 19 & Modern Component Architecture
- useRef Mechanics: DOM References And Mutable Persistent State — React 19 & Modern Component Architecture
- useImperativeHandle: Controlled Ref Forwarding Boundaries — React 19 & Modern Component Architecture
- Custom Hook Composition: Encapsulating Reactive Logic — React 19 & Modern Component Architecture