Redux-freeze is a Redux middleware designed to prevent accidental state mutations within a Redux application by deeply freezing the state object after each dispatched action. This mechanism helps enforce the core Redux principle of immutability during development, throwing a runtime error if any part of the state is modified directly. It is intended strictly as a development-time tool to catch bugs early, as its deep freezing operation introduces performance overhead unsuitable for production environments. The package is currently at version 0.1.7. Based on the lack of recent activity and a last commit several years ago, the project appears to be abandoned, with no active release cadence. Its primary differentiator is its straightforward, single-purpose approach to ensuring immutability, making it a clear diagnostic tool for identifying unintentional side effects in state management.
npm install redux-freezeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate `redux-freeze` into a Redux store and shows how it catches both direct state mutations within reducers and mutations on state objects retrieved from the store.
Ensure `redux-freeze` is only included in your Redux middleware stack during development builds, typically guarded by `process.env.NODE_ENV !== 'production'` or a similar conditional check specific to your build setup.
If performance in development becomes an issue, consider alternative immutability checks that might be less aggressive or optimize your Redux state structure to avoid excessive depth. For extreme cases, temporary disabling might be needed for specific development tasks.
Upgrade to version `0.1.7` or newer to ensure consistent state freezing behavior from the initial store setup and first dispatch.
Always update Redux state immutably. Instead of `state.prop = newValue;`, create a new object or array with the updated values. For objects, use the spread operator: `{ ...state, prop: newValue }`. For arrays, use `[...state, newItem]` or `state.map(...)`.Ensure you are using the correct import syntax for a default export. For ES Modules, use `import freeze from 'redux-freeze';`. For CommonJS, use `const freeze = require('redux-freeze');`.No dependency data recorded yet.