Just React.js Please

Ever since I laid eyes on React.js I fell in love with it. In fact, I was already writing pretty “React-like” HTML+JS at the time, but it was clear that it was many steps ahead of my thinking process.

// sample code of mine at the time

// toggle pushed location state
  state.watch('interface-progress:url-to-use', 'url-to-use', function(msg){
 
    var new_state, url, input, wrapper;
 
      wrapper =  document.getElementById('url-to-use-wrapper');
      input =  document.getElementById('url-to-use');
      new_state = msg.notice.state;
      url = msg.notice.url;
 
    if( new_state === 'reset'){
 
      state.notify('interface-progress:url-to-use', 'disabled');
      input.value = '';
      return;
    }
 
    switch( new_state ){
 
      case 'active':
        removeClass(wrapper, 'hidden');
        input.value = url;
      break;
 
      case 'disabled':
      default:
         addClass(wrapper, 'hidden');
      break;
    }
  });

Make a template of the DOM in Javascript, feed it the required data and React will auto-magically render it as efficiently as possible. The operations behind it is pretty logical, so it’s really more akin to a calculator than a sorcerer’s secret.

My biggest grief with fully adopting React.js is the sheer amount of technology the React community wants you to adopt to use it.

JSX to create your DOM representations. ES6 because its coming. Babel.js because ES6 isn’t here yet. Flux because the people who made React made it, so you’d probably like it too. Webpack. React-Router. The list goes on.

2090035[1]

I came for React.js. I don’t want a JSX transformer or a compile step. All this other stuff I’ll get to when I feel the time is right. In the meantime, show me plain code samples. Javascript only. Not ES6. I can’t use that without a compile step.

If you’re like me and all this other crap is getting in the way, I recommend James Nelson’s Guide to Raw React. Just React and Javascript.

You’re welcome 🙂