React is amazing

I've been using React for a bout a month now. I have to say it is probably the best peice of code I've enjoyed since Backbone. After using Typescript+Angular and hating ever moment of it. Working with React has been a breath of fresh air.

Not to say that React doesn't have it's weaknesses. I'm not a huge fan of precompiling and all the headaches that come along with it. I think that's just the way the world is though on the Front End right now and you just have to deal with it. React isn't nearly as enjoyable without JSX.

The main advantage of React is that it is simple.

/** @jsx React.DOM */

var LikeButton = React.createClass({  
  getInitialState: function() {
    return {liked: false};
  },
  handleClick: function(event) {
    this.setState({liked: !this.state.liked});
  },
  // render is the only required method
  render: function() {
    var text = this.state.liked ? 'like' : 'unlike';
    return (
      <p className='{this.props.color}' onClick={this.handleClick}>
        You {text} this. Click to toggle.
      </p>
    );
  }
});

// This is one way to bind your component to the dom. 
// It's more common to include other components within a component though. 
React.renderComponent(  
  <LikeButton />,
  document.getElementById('example')
);

Your components have properties and state. Everything else you can handle on your own with your own tools. The React website makes mention that they essentially just want to be the V in the MVC. I think that attitude of being small and modular is what makes React so wonderful.

We have been able to do some pretty cool stuff with react using JSDom and Browserify. I hope I get to write more about it soon. I'm specifically trying to figure out an effective way to unit test React components. If you have some advice, hit me up on twitter please!