With xstate, how can I access the machine's current state when predictableActionArguments=true

286 views Asked by At

My xstate error machine has an "error" state which logs as much debug information as possible on entry:

const myMachine = createMachine({
  states: {
    …,
    error: {
      entry: (context, event, meta) => {
        console.error(
          `Error in state '${meta.state?.value}' (origin: '${meta._event.origin}'): `
            + `${event.type} - ${(event as any).data}`,
        );
        console.error('Error stack:', (event as any).data);
      },
      …,
    },
  },
})

But when predictableActionArguments: true is set, the meta argument is no longer available, which makes the error message less helpful.

So, when predictableActionArguments: true, how can I determine the machine's current state and event origin?

0

There are 0 answers