Check out a free preview of the full State Modeling in React with XState course:
The "Invoking Actors Exercise" Lesson is part of the full, State Modeling in React with XState course featured in this preview video. Here's what you'd learn in this lesson:

Students are instructed to move the interval logic from the useEffect hook directly into the state machine.

Get Unlimited Access Now

Transcript from the "Invoking Actors Exercise" Lesson

[00:00:00]
>> Okay, so we're going to go to exercise seven, which is invoking actors. And we're going to move all of that interval logic that we have in the use effect, and we're going to put that in an invoked callback instead. So yeah, so you can see we removed the use effect over here, it's no longer there, even though it was in previous ones.

[00:00:34] This same use effect logic, that's gonna go inside of the timer machine instead. So in the running state, that's where we're going to invoke that callback, which is going to send a tick event on every interval, and you could grab that interval from the context directly there. And yeah, so essentially we're just refactoring the timer machine, so that that interval logic is within the machine itself.