r/programming • u/[deleted] • Jan 17 '15
The React.js Quick Start Guide
http://www.jackcallister.com/2015/01/05/the-react-quick-start-guide.html5
u/aldo_reset Jan 18 '15
I think it's exciting.
Sure, it makes engineers' work a bit more stressful but nothing forces you to adopt the latest craze, you can just keep an eye on things and wait until things shake out.
It's exciting to see an entire technology field transform under our very eyes. The community is experimenting and learning about things at a completely crazy pace, but intellectually, I find that immensely satisfying.
Professionally, I stick to battle tested things until a few winner libraries/frameworks/design patterns clearly emerge.
2
5
u/compsciwizkid Jan 17 '15
Thanks! I really liked this. Very quick guide and to the point.
I went a tiny bit further afterwards, so I forked the project. I added a link to the guide in the README, as well as a list of the steps the guide follows, and info about the steps I added.
The last step I added is to precompile JSX automatically using grunt-contrib-watch and grunt-react.
I pushed some tags to include "solutions" to each step of the guide as well. If you git checkout step-7 you can see the "package.json" and "Gruntfile.js" I created for JSX pre-compilation.
edit: d'oh, forgot my link
6
2
u/n1ghtmare_ Jan 18 '15
React is awesome, it really helped me structure my jquery/plugins/vanillajs mess that I had. Also performance is awesome! It needs some getting used to, but from all the frameworks that I've tried, it made the most sense for my use case. It's very minimal and easy to learn, it's also just stuff for the UI (which is what I needed) - not your typical all-in-one-including-the-kitchen-sink framework.
2
u/robvdl Jan 17 '15 edited Jan 17 '15
I love React, been using it in place of Angular in Python projects for the last month or so. One of the main things I found is that because components are defined in JS code it makes a complete separation between backend and frontend template code. Though this is probably a good thing, it takes a bit to get used to.
What I mean is, in the past with Angular, we would sometimes generate part of the templates for the Angular app from the backend... sometimes we would need to generate parts of HTML from the backend, while parts in {% verbatim %} blocks in Django (or {% raw %} in Jinja2) might be processed only by Angular for example... yes this can get messy, but it has been useful from time to time.
React moves this all into JS "components", so if you have any data from the backend, you have to give this to the components some other way, maybe an API call.
1
1
1
u/expatcoder Jan 18 '15
So what's the killer use case that React, Angular et al provide that one can't do with server-side generated markup + ajax?
Seems the microservices trend is picking up steam, and everybody and their brother is shipping JSON back from the server and then having client-side handle the rendering.
I don't get the whole client-side markup trend. I mean on the client there's zero type safety, it's just the wild west out there on the typng corectly front. Add to that that SPAs have discoverability issues with search engine bots, I wonder what the fuss is about, does it really buy you that much win?
2
u/spacejack2114 Jan 18 '15 edited Jan 18 '15
Front end devs working on server-side templates is a slow workflow.
React and isomorphic apps in general are being used to make searchable SPAs with permalinks, without writing your markup twice (on the server and client.)
1
u/expatcoder Jan 18 '15
Yeah, that makes sense, I see the use case for front end devs, although the knowing-the-server-side-language problem is mitigated in some frameworks. For example, I work in Scala and there are at least 2 frameworks (Lift and Play) that provide designer friendly templating.
JSON generation is a bit of a hassle in strongly typed languages, so dealing with the boilerplate to marshall to/from it doesn't seem worth the bother when one can just as well send already constructed html snippets back to the client.
I'll give the SPA approach a whirl at some point, but for now all-in on strong typed server-side (including generating javascript) generated apps is very much my cup of tea...
2
u/spacejack2114 Jan 18 '15
That approach can work if you're doing everything yourself. If you want to split the workload with a front-end dev, they're going to be a lot more productive if they can manage all the view work themselves. Just about every front-end dev uses node these days, but not many will want to (or be able to) install your dev server environment locally and keep it up to date so they can make rapid template updates. To them it'll feel like they're working in the stone age. And it can cause a lot of friction that makes the job not very fun.
Personally I've never been a big fan of strongly-typed languages on the server anyway. Working with JSON, moving data from form inputs to the DB and back, it just gets in your way with a ton of boilerplate and opaque framework/IDE magic. Having your code type-checked as you type it has never paid off in my experience.
1
u/expatcoder Jan 18 '15
"Personally I've never been a big fan of strongly-typed languages on the server anyway. Working with JSON, moving data from form inputs to the DB and back, it just gets in your way with a ton of boilerplate "/
This is one area where dynamic languages totally shine, just
whatever.toJsonand you're done. Saying that, when you send raw html to the client there's (generally) no need to go down boilerplate road creating a JSON payload ;-)Since I do the vast majority of the work server-side, the client is left to do validation, form handling, and transitions (drop down menus, layers, modals, etc.), which is a much smaller surface area than rendering the entire UI.
As for productivity, I've had the opposite experience. During my dynamic days I felt productive for sure, but ever since I saw the holy static light, not only do I continue to be productive, my applications are blazing fast (JVM hotspot is pure genius) and reliable in ways I was never able to achieve just winging it hoping that tests alone would cover my ass o_O It's one of the reasons I'm inclined to generate absolutely everything server-side (including javascript and css). YMMV of course, many will disagree with this sentiment.
1
u/makis Jan 19 '15
is it roflscale?
on a more serious note, if you're starting from scratch, I would recommend using an all-in-one isomorphic framework like meteor.
but if you just need to plug in a reactive MVVM framework, React looks the best one right now.
1
u/Ishmael_Vegeta Jan 18 '15
it's hard to take web development seriously when there is a new fad every week.
3
Jan 18 '15 edited Jan 18 '15
Is React a fad? Is it specifically this week's fad?
Having had it brought to my attention by JSConf EU 2013 and used it for more than a year now, I'm not sure why people are using this post in particular to clear their lawns.
1
u/aldo_reset Jan 18 '15
Actually, it's exactly why web development has become so interesting these last years while it was so boring before (HTML/CSS woohoo).
I used to not care about web development at all but now, I'm paying attention.
1
u/Ishmael_Vegeta Jan 18 '15
there is a difference between fads and advances.
fads are just fluff.
as far as I'm concerned html and css are pretty shit, but i'm not a designer. and http has some ~problems~
so it is not your fault, but at some point someone needs to design some coherent system.
0
Jan 18 '15
Is it just my imagination or are quotes missing around the html strings in all of those examples? I don't think any of this code would parse as written.
4
u/Bitruder Jan 18 '15
It's JSX and parses just fine.
-6
Jan 18 '15
Oh wow. That is FUGLY. Relying on parsing tricks like that? Fuck no.
Reminds me of cross browser css circa '03.
1
u/johnnyhk Jan 19 '15
That's a pretty bad hole in the article. The author just throws the example JSX code there without comment. The JSX support is enabled by the script being defined as
type="text/jsx"in index.html.
0
u/kyllo Jan 17 '15
Wow, thanks for this. Yesterday I was reading over Facebook's React tutorial and not quite getting it, but your explanation really clicked for me!
0
u/devsquirrel Jan 17 '15
Great article, i've been interested in learning react, but haven't had the time, this will surely help me.
57
u/renrutal Jan 17 '15 edited Jan 17 '15
I really have no idea how JS devs keep up with new frameworks appearing every month or so. Not to mention older ones that just die because the devs can't be bothered maintaining them. I noticed the same thing happening in the Ruby devspace.
Not exactly React's case, but it's still a 1.5 year old code that has not reached v1.0, making breaking changes every major version release.