DEV Community

Discussion on: State machine advent: Let the machine handle accessibility for you (18/24)

Collapse
codingdive profile image
Mikey Stengel Author • Edited on

Hey, thank you for reaching out. I'm glad you find them useful.

It's just a code preference and helps me think in events. One UI event handler = one event sent to the machine and possibly multiple actions, validations and side effects within the machine.

You can't ever do something like

<input onChange={(event) => void event.target.value && send({ type: 'WRITE', input: event.target.value}) /> 

As void true still yields undefined. Therefore, the event would never be sent. This forces me to write all the conditional code into the machine and keep as little logic in the UI as possible. 😊