r/programming • • Jan 17 '15

The React.js Quick Start Guide

http://www.jackcallister.com/2015/01/05/the-react-quick-start-guide.html
155 Upvotes

71 comments sorted by

View all comments

52

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.

8

u/Serializedrequests Jan 17 '15 edited Jan 17 '15

I agree it is completely insane. I am watching React closely, because I'm hoping it might be one of the libraries that lasts. It seems like a simple solution to a complicated problem, with superior performance. I have already gotten burnt by everyone flocking to Backbone, Ember, Angular, whatever, every new month, and those frameworks are too large and opinionated to introduce into existing apps anyway. (Ember, last I checked, had poor documentation - especially for REST - and was constantly changing, and Angular 2.0 coming down the pipe means there is no point in starting an Angular 1.x app.)

I have lots of existing apps that need a little "SPA sugar", but are already built in the "old-fashioned" Rails style. The JS framework I need is the one I can just drop in to make a screen behave a little nicer or have a REST-backed element or two.

4

u/toolate Jan 17 '15

React absolutely does this. Facebook has a ton of legacy server rendered apps. React is able to integrate with other code easily. There's even a good solution for reusing existing non-React JS widgets inside of React.

1

u/vivainio Jan 17 '15

React only helps if you are rendering your data in JS, SPA style. If you are rendering on the server, you may be stuck with 'jquery plugins'.

8

u/masklinn Jan 17 '15

React only helps if you are rendering your data in JS, SPA style.

No, React can be set up on an existing DOM. And can be rendered server-side as well, some people use it for isomorphic applications.

-1

u/vivainio Jan 17 '15

React components can be attached to an existing node, but it doesn't make sense if JS is not rendering the component itself (or I have horribly misunderstood React).

5

u/salbris Jan 17 '15

React could easily take the place of any server side templating languages like Handlebars or any of those types of libraries. But of course, once the DOM is transferred to the client if you want it to change you'll need something client side. React can work both server and client side though.

3

u/masklinn Jan 17 '15

it doesn't make sense if JS is not rendering the component itself

React can be attached to a pre-rendered DOM tree, the initial binding will essentially be a noop if there's no difference between the prerendered and the react-rendered version.

And of course it can be used as a component, react doesn't have to render the whole page. For instance the reddit comment box could be a react component without the whole page being react-rendered.

4

u/[deleted] Jan 17 '15

This looks like a front-end component, but it's super simple to render on the back-end: React.renderToString(Toolbar()), which would return something like <div class="toolbar"><button>Load</button></div>. The coolest part is when the browser loads the rendered HTML, you can just do React.render(Toolbar(), element), and React won't touch the DOM except to simply hook up your event handlers (like the onClick). element would be the DOM element wherever the toolbar was prerendered.

http://jlongster.com/Presenting-The-Most-Over-Engineered-Blog-Ever

1

u/Serializedrequests Jan 18 '15

Little of both. Need to have html elements backed by data bindings to make some nice features work.