Immer
A small JavaScript library that lets you write update code as if mutating an object, while it produces a new immutable copy for you.
In more detail
Immer gives you a draft object; after your function finishes it creates the next state with only the changed parts copied. It makes deeply nested React state updates shorter and less error-prone.
Related terms
- immutable — Something that cannot be changed after it is created; to change it you make a new one.
- mutation — A change to data, and in TanStack Query or tRPC specifically, a request that creates, updates or deletes data on the server.
- component state — Data a component remembers between renders, such as typed text or whether a menu is open; changing it makes React render again.
Taught in
- State with useState: Immutability And Asynchronous Batching — React 19 & Modern Component Architecture