Skip to content

Commit b0765e8

Browse files
fix(overmind): give different warning when transitioning to the same state
1 parent 6e990bb commit b0765e8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/node_modules/overmind/src/statemachine.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ class StateMachine<States extends TStates, State extends TStates = States> {
4242
this.state = state
4343
Promise.resolve().then(() => tree.blockMutations())
4444
return this
45-
} else if (process.env.NODE_ENV === 'development') {
45+
} else if (process.env.NODE_ENV === 'development' && state !== this.state) {
4646
console.warn(`Overmind Statemachine - You tried to transition into "${state}", but it is not a valid transition. The valid transitions are ${JSON.stringify(transitions[this.state])}`)
47+
} else if (process.env.NODE_ENV === 'development' && state === this.state) {
48+
console.warn(`Overmind Statemachine - You tried to transition into "${state}", but you are already in this state. Do a "match" before running this piece of logic`)
4749
}
4850
}
4951
matches(state) {

0 commit comments

Comments
 (0)