Getting Going with React

PUBLISHED ON FEB 21, 2015 — IMPORTED FROM TUMBLR, TEXT

Part I: Before I Typed a Single Curly Brace or Semicolon

When I first saw some JSX code in a tutorial on React, I immediately poo-pooed the whole library: “What is that, HTML in JavaScript? Facebook, grrr! I’m no wizard, but that’s a terrible combination of concerns! Also, it’s ugly and please give me back my Jade, immediately.” But, as time went on and as one of my co-workers continued his incessant gushing about React, I finally broke down and gave it a spin. And I really, really liked it.

“HTML in JavaScript?”

That’s what it looks like, but it’s really not. In reality, it’s a way of asking the JSX transpiler to later create some HTML that looks like it. A small distinction, yes, but for some reason, learning that distinction helped assuage some concerns.

“Faceook, grrr!”

Nothing will change this. I take solace in the fact that FB—as a self-serving organization that treats its users as cattle—will one day go the way of AOL, who once thought they ruled the internet. [Note the lack of disparagement for the individuals involved with the company.]

“a terrible combination of concerns!”

This had to be pointed out to me: Angular actually has tightly-coupled views and controllers. Change the ID of a button in the view? Gotta update that ID in the controller. With React, the scripting and the output are all right there, in the same React.createClass.

“it’s ugly and please give me back my Jade”

There’s no getting around the fact that it is ugly. As far as having to sully my code with < and >, there are options to explore.

So, with all of this in mind, I put on this video from React.js Conf the other night at around 9pm, and ended up working until 2am on my first React project. Blast.

A Note on Testing

Testing doesn’t seem to be as integral to development as it is in Angular. Take, for instance, the Angular tutorial that walks one through the building of an app for phone shopping. Testing makes up a significant portion of that experience. With React, though? Not so much — the test utilities are included only in an add-on. Even though there’s research that concludes that TDD doesn’t result in less buggy or more quickly-developed code, getting a test suite to green triggers an endorphin release in my brain that I really quite enjoy.

Next time: my first React project - a rebuild of my personal website. Or maybe I’ll go through the React + Jade tools. Or maybe I’ll build an actual dang app.