4 ms·
What you described is exactly what I’ve been doing when building UIs. All of the logic of the front end application is completely outside of the view layer. I t
by amw-zero 6y ago
What you described is exactly what I’ve been doing when building UIs. All of the logic of the front end application is completely outside of the view layer. I think this coupling of the view vs. the front end application is bad, and it’s the most common default mode.
Then, the view has only minimal logic. Like you mentioned, it does require some code, like mapping over an array to create the individual rows of a table. You also need one level of if branching, because sometimes you need to show or hide a UI element based on some state.
But that’s it. I don’t even render components when testing generally. The setup code for actually rendering UI is very brittle, and when was the last time your bug was that you called the wrong function in response to a button click? The small layer between the UI framework and the brains of the application is best tested by actually looking at the rendered view anyway. Its completeness is qualitative.
Anyway, I’m really fond of this approach and wish more front end devs were open to doing it.