In this exercise, you're going to be creating a state machine from scratch, and putting it in useReducer
.
- Create a state machine reducer with 3 states:
idle
,running
, andpaused
.- The state machine should start in the
idle
state. - When a
TOGGLE
event occurs inidle
, the machine should transition torunning
. - When a
TOGGLE
event occurs inrunning
, the machine should transition topaused
. - When a
TOGGLE
event occurs inpaused
, the machine should transition back torunning
. - When a
RESET
event occurs inpaused
, the machine should transition back toidle
.
- The state machine should start in the
- Dispatch those
TOGGLE
events when the Start timer and Pause timer buttons are pressed. Additionally, clicking on the elapsed time should also start the timer. - Only show the Pause timer button when the
state
is'running'
. - Only show the Start timer button when the state is either
paused
oridle
.