Awesome
mutative-compat
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
freeze
function will only freeze shallowly, the second argumentdeep?: boolean
is omitted. - In nested
produce
calls, 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