by bellerocky · 12y ago · 0 comments
Personally, I have found react.js to be much better than Angular but in any case I found your comment to be filled with a heavy use of unwarranted intensifiers ("far superior") and some amount of fortune telling.
Front-end development is a fast moving field, and the new ECMAScript 6 changes, as well as further browser updates, will probably shake up the scene, but it's hard to predict what will happen. I doubt that we'll reach a point of stability any time soon where you didn't have to throw out at least some decent amount of code after 5 or 6 years due to library changes and browser updates.
This is a tangent, but can you explain why?
In my opinion the approach that React takes (as well as its siblings like Mithril and Ractive) will eventually be the default approach, even for the bigger frameworks (new or 'refactored').
Angular has some fair parts (testing, resources) and some really convoluted and what's more important bug ridden parts (directives and scopes).
Do you want composability? Write a bunch of element directives and nest them -- it'll end up looking almost exactly like React's classes and components. The main difference is that in React you throw away MVC and replace with with a big ol' render() function that spits out "HTML" (well, a shadow-DOM version of it anyway)
Scopes are just objects that use prototypal inheritance to inherit from outer scopes. Create an new (isolated) scope in your directive to isolate data to that component and its subcomponents.
Also, using AngularUI Router is essential.
As for composability they did not seriously thought this through. One bug I found out, the one that got fixed, showed up for anone who created two directives with isolated scope and transclusion, one used in template of the other. Basically isolated scope of outer directive got transcluded into inner one instead scope outer in relation to outside directive.
Scopes suffer from the same flaws that with() statement in js suffers mainly that when you assign inside it will be assigned not where you at first expect (current leaf scope not the scope of closest controller). When you add to this the fact that humble ng-model assigns you have a huge hole that nearly all newbies fall into at least once.
Another gripe is that angular doesn't eat it's own dogfood. For example ng-required is not a directive. It's just attribute parsed internally by input directive.
AngularUI router is worthless if you need to have multiple tabs inside your web app as it allows you to have just one branch of views tree shown at any given time. There are suggestions about implementing parallel subviews but last time I checked it was too hard for them.
Angular is set of legos with lots of weird pieces. React is blueprint how to make your own bricks so they fit together and won't turn into tower of ugly chaos when assembled.
I was distrustful towards virtual dom at first. But that's just a way of batching and saving dom changes. The architecture that's enabled by it is all about composability and maintaining control over your project.
Simply put, no. React.js can be treated as a simple, dumb view or part of something larger ala Backbone, Flux, etc..
Angular.js doesn't even have a model layer aside from $scope, which in my experience is being thrown away more and more in favor of controllerAs syntax & convoluted services masquerading as 'models'