Skip to content

Commit

Permalink
Add Tips and Tricks section with replacing state instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
skoshy authored Nov 3, 2019
1 parent c9fc370 commit ba02b3b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,29 @@ Here's a more complete example with redux-saga and [redux-render-prop](https://g

<https://github.com/epeli/typescript-redux-todoapp>

## 🃏 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

The module exports following helpers
Expand Down

0 comments on commit ba02b3b

Please sign in to comment.