Facebook’s New React JavaScript Library Tutorial Rewritten in AngularJS
medium.com
medium.com
Though, comparing code snippets to a lengthy tutorial kind of misrepresents the verbosity of React. I think we forgot to put the completed tutorial on GitHub, so here it is for an easier comparison:
https://github.com/petehunt/react-tutorial/blob/master/scrip...
Outside of standard HTML boilerplate our entire application is pretty small I think.
We also have a demo of Backbone integration, too:
https://github.com/facebook/react/tree/master/examples/todom...
Well, I think most would agree that AngularJS has better readability and is more concise but a disclaimer would be that I've been looking at Angular's syntax for quite some time and reactjs is a new framework...Instagram's website is nice by the way, simple, clean UI.
The "Load More" Button on the site is probably powered by reactjs? @peterhunt
> For our comment box example, we'll have the following component structure:
>- CommentBox
> - CommentList
> - Comment
> - CommentForm
Yet the AngularJS solution simplifies this down to one component.
If we presume React could simplify down to a single component too, then the AngularJS solution is would only be fair if it keeps the artificial constraint of having four component classes.
The equivalent in Angular would be to use directives (http://docs.angularjs.org/guide/directive) for the comment list, each comment, and each part of a comment.
Passing data between parent and child components (via scope) becomes a little tricky.
I do think that components which consist entirely of JS are convenient (self-contained w/ no ancillary HTML assets). Not sure it's enough to justify the framework, but has some potential.
What I don't understand is how you add login while keeping your REST backend stateless. How do you validate the request and make sure that it comes from the correct user and not just someone who forges the request without keeping a state on the server-side? Normally you just add a session.
http://www.frederiknakstad.com/authentication-in-single-page...
I think Facebook.com does something similar.
Just a couple ideas.
+1 for AngularJS
And yes, that was intentional.
I wouldn't even be surprised if the book is totally out of date in a few months.
I'm only 2 chapters into it, but it is excellent so far. If you search for Packt coupons, you can pick up the ebook for around $16.
Some people prefer the more traditional editor interface.
In small examples (ie when not using angular routes) it is easier to explicitly specify the controller.
Having said all that, I'm really impressed with React and look forward to checking it out and using it in combination with Backbone. AngularJS definitely has its share of pain points. It's just that where the controller is linked to the view is not one of them.
(By the way, I'm upvoting you since I don't see anything particularly offensive or improper about your comment. We're just disagreeing. Not sure why you're being downvoted. )
But I do agree on the point that designers would certainly gag when seeing this... A developer would need to go though the deign and insert all the hooks. This step is unavoidable with any web application framework.
That being said, I think a designer would puke if they were required to write React components.
As for making up your own elements as angular allows you to do, I think this is actually quite forward thinking. This is basically what the ShadowDOM[0] is all about, and when becomes common place you won't bat an eyelid seeing <NoBleachsSuperTag> in HTML.
[0] http://www.html5rocks.com/en/tutorials/webcomponents/shadowd...
you can certainly use <li class="some_style_class" data-ng-repeat="comment in comments"> in your angular templates and have it pass a validator for html5 and still work with angular.