Simple States And Composite States
const machine = createMachine({
// Starting State
initial: "active",
// Starting Context
context: { count: 0 },
// States
states: {
inactive: {
always: { target: "active" },
},
active: {
on: {
SWITCH_COUNT_DIRECTION: {
actions: ["logSwitch", "consoleLogSwitch"],
},
COUNT: {
actions: "changeCount",
},
},
initial: "increment",
states: {
increment: {
on: {
SWITCH_COUNT_DIRECTION: "decrement",
},
},
decrement: {
on: {
SWITCH_COUNT_DIRECTION: "increment",
},
},
},
},
},
});Last updated