Hacker News new | ask | show | jobs
by dustingetz 352 days ago
UI is not just DOM it is also network connections, events from the user, and local state. React only datafies the DOM orchestration. The UI=f(state) composition model fails at all of these points, most vividly at the network boundary, but does not include answers for the other domains I listed as well.
1 comments

Right, but when actually working on UIs, do you need to replay the actual side-effects of those things, or just whatever happened before/after of that?

Personally I split those things up into two parts, and only iterate on the UI with "static data" that either exists before, during or after. So testing/iterating on things like "Click button, loading animation plays while network request is in flight, show success/failure" is essentially 4-5 "static" states, and you don't really have to care about what happens in-between much except for corner-cases.

in my opinion it is the events and state transitions that are where everything interesting and challenging happens, like server IO in mount/unmount/didUpdate lifecycle methods or event callbacks. For example, a typeahead component. You focus the input and start typing. The picklist unfolds and loads records from the server, we need to stream subsequent keystrokes to the server into the query for server filtering, we need to maintain the DOM gracefully as the query changes stream in, we need virtual scroll if the collection is large, the user then uses the arrow keys to select an item in the picklist and presses enter to submit, closing the picklist and returning the selection to the caller. It is a living, reactive process. Now "use the REPL" to get, like, any value at all?