Advanced Guides
Freezing, currying, marks, patches, strict mode, TypeScript, pitfalls, performance, and migration from Immer and from Mutative v1.
Auto Freeze
Freeze the next state deeply with enableAutoFreeze, so that accidental changes to it fail.
Currying
Create producers that take the base state and more arguments, and drafts that you finalize later.
Marking data structure
Decide with the mark option which values Mutative drafts, which it leaves mutable, and how it copies them.
Patches
Record the changes of a recipe as patches, and apply them to a state with apply().
Strict Mode
Make reads of values that Mutative does not draft explicit, and check returned values in development.
TypeScript
How Mutative types drafts, results, producers and patches, and the types and casts it exports.
Pitfalls
Common mistakes with drafts, returned values, values that are not drafted, and patches, and how to avoid them.
Performance tips
Write recipes that avoid needless drafts, searches, copies, freezing and patches.
Migration from Immer to Mutative
Replace Immer's APIs with their Mutative counterparts, and check the defaults that differ.
Migration from Mutative v1 to v2
The changes since Mutative 1.3.0 that can affect existing code, in builds, patches, arrays, returned values, development builds, types and fixes.
Edit on GitHub
Last updated on by unadlib