Take this finite-state machine:
{
initial: "foo",
states: {
foo: {
on: { BAR: "bar" }
},
bar: {
on: { FOO: "foo" }
}
}
}
And in my component, I do this:
import { useMachine } from "@xstate/react";
export default function() {
const [current, send] = useMachine(machine);
useEffect(() => {
send("BAR");
}, []);
return (
<>
Hello World
</>
);
}
This is perfectly valid code and the machine will switch to the "bar" state. Now, what happens if I do this?
useEffect(() => {
send("QUX");
}, []);
The QUX
event is not defined in the machine.