Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: SpawnChild input does not see current event #5024

Open
xylophonehero opened this issue Aug 8, 2024 · 0 comments
Open

Bug: SpawnChild input does not see current event #5024

xylophonehero opened this issue Aug 8, 2024 · 0 comments
Assignees
Labels

Comments

@xylophonehero
Copy link
Contributor

xylophonehero commented Aug 8, 2024

XState version

XState version 5

Description

When calling spawnChild in the actions of an event, the input function does not filter to just the event but rather all events in the schema

Expected result

const myMachine = setup({
  types: {} as {
    context: TranscriptionsMachineContext
    events:{ type: 'foo'; value: string } | { type: 'bar' }
  },
}).createMachine({
  on: {
    foo: {
      actions: spawnChild('myActor', {
        input: ({event}) => event.value // HERE
       })
     }
  }
})

event.value should be fine to access

Actual result

event.value is not accessible as the event could be anything event in the schema, not just foo

Reproduction

https://codesandbox.io/p/devbox/wizardly-solomon-7vskzv?file=%2Fsrc%2FfeedbackMachine.ts%3A46%2C16

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants