Joshua Hornby

Lessons learned from building an app with React.js

Tags : React

A brief overview of what I have learnt when using React.js on a modern web applciation.

The Stack

JavaScript Everywhere

I’d also like to extend thanks to Ken Ding and his brilliant boilerplate application.

Why React?

This is a very good question, after some failed experiments using ember.js React seemed the next logical choice. A major plus point was the fact that we could render both the client and server in JavaScript, something which is kown as universal JavaScript.

Thinking dumb

The biggest question we had when writing our React application was, ‘what is the correct way to write compontents?’ The answer came from the fantastic Dan Abramov and his article on smart and dumb components

We then began a refactor and splitting most of our components into data fetching smart components and prop rendering dump components. This is where we found AltContainer extremely useful, a higher-order container component but also known as the swiss army knife of the alt world. This allowed us to remove a lot of the alt.js boilerplate code and focus on writing simple, clean and maintainable JavaScript.

Universal JS can be painful

Due to the server side rendering aspect of Universal JS this can lead to a few headaches along the way, one of our biggest was when we wanted to use external libraries, for example using the React Highcharts package we had issues with getting this package to work in a server side application. Although this isn’t a reason not to build Universal JS apps its something to take on board, and be prepared for the odd hacky fix.

The Future

comments powered by Disqus