Redux Freezer

Immutability is a fundamental part of how Redux stores work when used to follow the State-Action-Model pattern.

Using a library such as immutable.js is recommended for the efficient deep object comparisons. However, when you are limited to using only ES6/lodash syntax in your web application, immutability can be hard to enforce when passing and mapping properties to React components or even within reducers themselves.

To help enforce immutability, I’ve created a Redux middleware to deep freeze the Redux store state after every update. Deep freeze is done using Object.freeze and is supported by the latest browsers. HTML elements are omitted during the freeze process. React components in your store may break. Not including HTML elements or React Components in your Redux store is typically recommended as a best practice.

Check out Redux Freezer on GitHub and NPM.

Comments Off on Redux Freezer

Categories random