Description
Using the counter example state machine I persist it like described in the docs
json = JSON.stringify(machine.state)`
Then later I want to load that state into my state machine
const counterService = interpret(counterMachine)
.start(counterMachine.resolve(State.create(JSON.parse(json))))
Expected Result
I was expecting this work.
Actual Result
I am getting the error:
Child state 'actions' does not exist on '(machine)'
Reproduction
Looking at the persisting state docs it looks like you want resolveState rather than resolve.
So your example would go from:
interpret(machine).start(
machine.resolve(
State.create(
JSON.parse(json)
)
)
);
to:
interpret(machine).start(
machine.resolveState(
State.create(
JSON.parse(json)
)
)
);
It certainly looks like it! Silly me. What is machine.resolve for then?
What is
machine.resolvefor then?
That is for resolving a state value, not a full state.
For example, someMachine.resolve('a') might return { a: { b: 'c' } }.