Prevent Impossible States Pt. 3 - A UI Driven by State
Use the timer's state machine to drive a React UI, with controls that match its current status.
Use the timer's state machine to drive a React UI, with controls that match its current status.
Model a timer's states and events with TypeScript unions, then define the rules for moving between them.
Use TypeScript discriminated unions to require the right fields, narrow object types, and catch unhandled cases.