You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 })
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 })
One option: when spawning, include a ref to the parent in the input for the child, i.e., input: {parent: self}, then in the child, take that input into its context; when it comes time to do a sendParent, do so conditionally -- only if context.parent exists.
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 [email protected]
The text was updated successfully, but these errors were encountered: