3 ms·
We're past static view components. Today UI elements are dynamic things and the code that drives the dynamics should be kept close to the static representation
by thibauts 10y ago
We're past static view components.
Today UI elements are dynamic things and the code that drives the dynamics should be kept close to the static representation of a given view state.
React actually separates UI code and interaction logic, as it should, by hosting the static part in the render function and the dynamic part in event handlers defined on the component. This is in my opinion a great balance of SoC / cohesion as it allows proper scoping of a UI unit and fosters controlled reuse.
I don't want to sound rude but we've had enough of this MVC fanatism that completely disabled many developer's creativity and took a lot of courage and energy to the React team, among others, to challenge.
Tying view logic (and only view logic) to static UI code is probably the only way to go on the path to proper UI component sharing and reuse. Whether we like it or not, whether we put the code in separate files or use any other artifice we're bound to make these two walk hand in hand. The last bastion being style. Which the React community tried to address, too.
At the risk of saying something obvious, I think we shouldn't reason on principles and habits. Progress can't be, and never is, driven by such forces.