Nice solution! I've had a very similar problem recently and tried out the approach above, but I also needed fully context support (it should preserve the context object when going back), so I built my xState wrapper which supports this: github.com/marcelkalveram/xstate-u...
It's not perfect and has other downsides (no redo, doesn't work with interpreted machines) but I thought I'd share it regardless in case anyone stumbles upon this post and is looking for the kind of wrapper I made.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice solution! I've had a very similar problem recently and tried out the approach above, but I also needed fully context support (it should preserve the context object when going back), so I built my xState wrapper which supports this: github.com/marcelkalveram/xstate-u...
It's not perfect and has other downsides (no redo, doesn't work with interpreted machines) but I thought I'd share it regardless in case anyone stumbles upon this post and is looking for the kind of wrapper I made.