Open dhensby opened 1 week ago
This is currently by design - it is a breaking change to change this to a warning instead of an error currently 🤔
Fair enough - I suppose this is more a docs issue, then?
Is there a way to nicely achieve this (optional send to parent)? Or maybe the options sent to the sendParent
could have a new property to allow it to be optional? eg: sendParent(() => ({ type: 'init' }), { allowMissingParent: true })
XState version
XState version 5
Description
The docs for
sendParent()
state (emphasis added):However, when running
sendParent()
as an action an error is thrown (Error: Unable to send event to actor '#_parent' from machine '(machine)'.
).Code to reproduce:
Expected result
I expect that no error is thrown and the
sendParent()
action becomes a no op when no parent exists.Actual result
The following error is thrown:
Error: Unable to send event to actor '#_parent' from machine '(machine)'.
Reproduction
see description
Additional context
Reproduced with xstate@5.18.2