immer-reducer
Advanced tools
Comparing version 0.7.8 to 0.7.9
{ | ||
"name": "immer-reducer", | ||
"version": "0.7.8", | ||
"version": "0.7.9", | ||
"description": "", | ||
@@ -42,4 +42,4 @@ "main": "lib/immer-reducer.js", | ||
"dependencies": { | ||
"immer": "^1.4.0 || ^2.0.0 || ^3.0.0 || ^4.0.0" | ||
"immer": "^1.4.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0" | ||
} | ||
} |
@@ -287,2 +287,25 @@ # immer-reducer | ||
## 🃏 Tips and Tricks | ||
You can replace the whole `draftState` with a new state if you'd like. This could be useful if you'd like to reset back to your initial state. | ||
```ts | ||
import {ImmerReducer} from "immer-reducer"; | ||
const initialState: State = { | ||
user: { | ||
firstName: "", | ||
lastName: "", | ||
}, | ||
}; | ||
class MyImmerReducer extends ImmerReducer<State> { | ||
// omitting other reducer methods | ||
reset() { | ||
this.draftState = initialState; | ||
} | ||
} | ||
``` | ||
## 📓 Helpers | ||
@@ -289,0 +312,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29215
409
+ Addedimmer@5.3.6(transitive)
- Removedimmer@4.0.2(transitive)