Immer plugin for Rematch. Wraps your reducers with immer, providing ability to safely do mutable changes resulting in immutable state.
Install the correct version of immer plugin based on the version of the core Rematch library in your project.
Immer plugin accepts one optional argument - config, which is an object with the following properties:
whitelist] (string): an array of models' names. Allows defining on a model level, which reducers should be wrapped with immer.
blacklist] (string): an array of models' names. Allows defining on a model level, which reducers should not be wrapped with immer.
If config isn't provided, reducers from all models will be wrapped with immer.
In Immer, reducers can perform mutations to achieve the next immutable state. Immer doesn't require that you return the next state from a reducer, but @rematch/immer plugin expects you to do it! Your reducers must always return the next state. Otherwise, you will reset your model's state. See the example below for details.
If your state is a primitive value like a number of a string, plugin automatically avoids using immer to execute the reducer, because immer can only recognize changes to the plain objects or arrays.