Check out a free preview of the full State Machines in JavaScript with XState, v2 course
The "History States Solution" Lesson is part of the full, State Machines in JavaScript with XState, v2 course featured in this preview video. Here's what you'd learn in this lesson:
David walks through the solution to the history states exercise.
Transcript from the "History States Solution" Lesson
[00:00:00]
>> Over here instead of targeting the ready states, we want to target a history state instead so that we can remember what child state of the ready state we were already on. So we currently have the pausing playing state. And now we just need to add a history state here which I'm just gonna call hist.
[00:00:19]
And I'm gonna give it a type of history. And we're going to target that ready hist states, which is represented here by .chaining we have ready .hist so we could target this child state right here. So now just by doing that when we're playing and we skip to the next song.
[00:00:45]
We're still playing, and so now if we're paused and we skip to the next song, now we're paused again, so we see that our history states still works.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops