React Xstate spawn machine with machine options

195 Views Asked by At

Is there any way to pass machine options such as "guards" and "delays" to a spawned machine either through the "spawn" function on the parent machine or the "useActor" hook on the context property?

1

There are 1 best solutions below

0
On BEST ANSWER

After a while, I find out about the "withConfig" method on the machine. You can use it like this.

assign({
            machine: () => spawn(someMachine.withConfig({
                guards: {
                  //...
                },
            })),
        })