...

/

Using Immer for Temporary Mutations

Using Immer for Temporary Mutations

Learn how to use Immer to resolve temporary mutations.

We'll cover the following...

A word from our friend Michel Weststrate, creator of MobX and Immer:

When writing reducers, it can sometimes be beneficial to use mutable objects temporarily. This is fine as long as you only mutate new objects (and not an existing state) and as long as you don’t try to mutate the objects after they have left the reducer.

Immer is a tiny library that expands this idea and makes it easier to write reducers. It is comparable in functionality to the withMutations() method in Immutable.js, but applied to regular JavaScript structures. With this approach, ...