XState v6 alpha
Inspect actor systems
Observe actor lifecycle, events and transitions.
XState v6 is in alpha
APIs and behavior may change before the stable release.
Pass an inspector to createActor(...) to observe the root actor and its children.
const actor = createActor(machine, {
inspect: (event) => {
if (event.type === '@xstate.transition') {
console.log(event.eventType, event.snapshot);
}
}
});
actor.start();Use inspection for developer tools, logs and telemetry. Do not put application decisions in an inspector.
Inspection can show actor activity in a development panel or attach the last transition to a failed backend request trace.