3 ms·
React manages the state of the UI, all the props and the virtual DOM counts as state. The declarative part is that the UI is recomputed from the state sorta-ex
by afiori 2y ago
React manages the state of the UI, all the props and the virtual DOM counts as state.
The declarative part is that the UI is recomputed from the state sorta-ex-novo at each update
- ajkjk 2y agoSure but the essence of it, the reason that it works, is that it shims a declarative architecture into JS. It works because it turns out UI programming works better in a declarative style.The fact that that involves managing state is secondary. I expect that in fifty years all programming will look declarative, either like HTML (which is sorta 'natively declarative') or more like React (which shims it into an imperative language).
- afiori 2y agoState management is not secondary, it is how it can implement the declarative UI with declarative updates.
- ajkjk 2y agoThat is a silly way to phrase it. It's secondary in the sense that of course a UI framework has to manage state. They all do that if they're complex at all. The state management is not what distinguishes React from other frameworks; it is distinguished by the (pseudo-)declarative API that it presents to the programmer.