MicheleBertoli / react-automata

A state machine abstraction for React
MIT License
1.34k stars 60 forks source link

Question: Is history nodes supported ? #84

Closed larsbuch closed 6 years ago

larsbuch commented 6 years ago

Typically it is desirable to have the possibility to go back to the state that you came from.

This can be handled with at history transition. My problem is that it stays at the history state instead of changing to the previous state

`const initialState = "a";

const statechart = { initial: initialState, states: { a: { on: { NEXT: "b", PREVIOUS: "hist" }, onEntry: "sayHello" }, b: { on: { NEXT: "c", PREVIOUS: "hist" }, onEntry: "sayCiao" }, c: { on: { NEXT: "a", PREVIOUS: "hist" }, onEntry: "sayHej" }, hist: { type:"history", history: "deep", target: initialState } } }; `

My test code

larsbuch commented 6 years ago

Can I accomplish this with 'react-automata' ?

ferdinandsalis commented 6 years ago

Hi @larsbuch, you are using changes that have been introduced in xstate 4 (described here. However react-automata depends on xstate 3 which uses a different way to declare history states. See this https://xstate.js.org/docs-v3/#/guides/history. I hope this helps.

MicheleBertoli commented 6 years ago

Thanks @larsbuch for opening this issue, and @ferdinandsalis for answering the question. Let's use #82 to track the future of this library.