Skip to content

Cannot read properties of undefined (reading 'onError') #500

@tnortman-jabra

Description

@tnortman-jabra

Reproducible Sample

import type { AnyEventObject } from 'xstate';
import { fromCallback, setup } from 'xstate';

const SomeActor = fromCallback<AnyEventObject, { thing: string }>(({ input }) => {
  console.log('SomeActor', input);
});

const AnotherActor = fromCallback<AnyEventObject, { otherThing: string }>(({ input }) => {
  console.log('AnotherActor', input);
});

export const MyMachine = setup({
  types: {
    children: {} as { someActor: 'SomeActor'; anotherActor: 'AnotherActor' },
  },
  actions: {},
  actors: {
    AnotherActor: AnotherActor,
    SomeActor: SomeActor,
  },
}).createMachine({
  id: 'ambient-noise-monitor',
  initial: 'Starting',
  invoke: [
    {
      id: 'someActor',
      systemId: 'my-actor-system-id',
      src: 'SomeActor',
      input: () => ({ thing: 'left' }),
      onError: {
        target: '.State Two',
      },
    },
    {
      id: 'anotherActor',
      systemId: 'my-actor-system-id',
      src: 'AnotherActor',
      input: () => ({ otherThing: 'SomeEvent' }),
      onError: {
        target: '.State Two',
      },
    },
  ],
  states: {
    Starting: {},
    'State Two': {
      type: 'final',
    },
  },
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions