Is there a way to replace the draftState with a new state? See the immer Readme for an example
Key line is here:
It is also allowed to return arbitrarily other data from the producer function. But only if you didn't modify the draft. This can be useful to produce an entirely new state.
Can the same be done with functions in an ImmerReducer? My use case is to completely reset the state back to the original state. The alternative I'm doing is looping through all the keys of this.draftState and setting those equal to the initial state.
Is there a way to replace the
draftState
with a new state? See the immer Readme for an exampleKey line is here:
Can the same be done with functions in an ImmerReducer? My use case is to completely reset the state back to the original state. The alternative I'm doing is looping through all the keys of
this.draftState
and setting those equal to the initial state.