Skip to content

Commit 18105cb

Browse files
fix(overmind): exclude base state keys on resetting statemachine state
1 parent 08afccf commit 18105cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/node_modules/overmind/src/statemachine.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ export class StateMachine<Base extends IState, States extends TStates, State ext
9191

9292
if (transitions[this.state].includes(state)) {
9393
const tree = (this[PROXY_TREE].master.mutationTree || this[PROXY_TREE])
94-
const base = this[VALUE][BASE]
94+
const baseKeys = Object.keys(this[VALUE][BASE])
9595

9696
tree.enableMutations()
9797
this[VALUE][CURRENT_KEYS].forEach((key) => {
98-
delete this[key]
98+
if (!baseKeys.includes(key)) {
99+
delete this[key]
100+
}
99101
})
100102

101103
Object.assign(this, newState)

0 commit comments

Comments
 (0)