3 ms·
The reasons why you should like react - forces you into an object oriented paradigm with constructors/destructors - mutation from external sources and interna
by formula1 10y ago
The reasons why you should like react
- forces you into an object oriented paradigm with constructors/destructors
- mutation from external sources and internal sources results in a single function being run to refresh the output.
- inline html/xml is your freind. You can see easily how a ui is structured rather than parsing a 300 line file to see what gets created, destroyed, appended, prepended anD etc
- all jsx results in is a "patch". This "patch" is then compiled into components (which also result in a "patch") or html elements/text/null values. This makes reasoning about the application simpler since a "controller" component may not care about updating canvas info. But the "canvas" component certainly does
- kierenj 10y agoI respectfully disagree. You don't need constructors and certainly not destructors (really not sure what you mean by this in the context of React, can you elaborate) and these are not really the main OO concepts. Polymorphism, inheritance are, but you don't refer to these? There is no inline XML, and I'm not aware of any other popular (or otherwise) React alternatives where you use long files which create, destroy, append and prepend DOM elements? I'm also not sure what you mean by patch, or what the specific benefit you're highlighting here is - just modularity? You can do that with any framework, it doesn't seem unique to React - at all?
- formula1 10y agoComponent will mount/component did mount is effectively construction. Component will unmount is effectively destruction. Apparently them changing the names makes you believe thats not what it is Polymorphism and inheritance can be implemented if you wanted. Mixins were used for a while. Xml is react native and all other alternative rendering that use jsx syntax and a form of react React alternatives where you create/destroy/append/prepend would be the DOM. Patching is interesting in that the inline html isnt actually html until the end of the render loop. I dont remember seeing that anywhere else to be honest. It seems more similar to transforms like in node streams.
- fleetfox 10y agoIf anything it forces you into it is functional paradigm (especially if you use flux/redux) with every component beeing a function of state. You mentioned it yourself in second point. To me react does not seem object oriented at all, at least in traditional way.