3 ms·
> React and Vue [...] exist so that you write your application in a declarative way where the view is rendered as a function of state Exactly. To elaborate, he
by klabb3 5y ago
> React and Vue [...] exist so that you write your application in a declarative way where the view is rendered as a function of state
Exactly. To elaborate, here's the big, big caveat in a miniature form:
https://github.com/1Marc/todomvc-vanillajs-2022/blob/854dd40bdf0facfdcdbd116b6c37dee906168254/js/app.js#L82 https://github.com/1Marc/todomvc-vanillajs-2022/blob/854dd40...
Note that this clears and recreates the DOM on every action (eg mark complete), and DOM ops are the most expensive ones. This is a sound strategy for vanilla JS, because the alternative is mutating the DOM and keeping it in sync which is error prone to put it mildly.
I use frameworks very sparingly, and am always cautious with deps. But a reactive UI/diff engine is non-negotiable for me.