React Xstate spawn machine with machine options

178 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 answers

0
DiniMad 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: {
                  //...
                },
            })),
        })