mutative-compat
December 27, 2023 ยท View on GitHub
Mutative wrapper with full Immer API compatibility.
Installation
# npm
npm install mutative-compat mutative
# Yarn
yarn add mutative-compat mutative
# pnpm
pnpm add mutative-compat mutative
Optional but useful ๐:
// package.json
{
"dependencies": {
"immer": "npm:mutative-compat@^0.1.x",
"mutative": "^1.0.2",
},
// npm
"overrides": {
"immer": "npm:mutative-compat@^0.1.x"
},
// Yarn
"resolutions": {
"immer": "npm:mutative-compat@^0.1.x"
},
// pnpm
"pnpm": {
"overrides": {
"immer": "npm:mutative-compat@^0.1.x"
}
}
}
This way you can replace immer with mutative in some opinionated libraries like Redux Toolkit.
Differences from Immer
- The
freezefunction will only freeze shallowly, the second argumentdeep?: booleanis omitted. - In nested
producecalls, the inner results will never be frozen even if they're not used in the outer recipe.
For other differences (that you probably will never notice), see mutative/test/immer-non-support.test.ts
License
MIT License @ 2023-Present Xuanbo Cheng