The genesis of the project:
- topheman/react-es6: A simple app based on React, coded in ES6, relying on topheman-apis-proxy as a backend (providing the github API).
On october 7th, 2015, Facebook released the v0.14 of React. I took it as an opportunity to get back at React and upgrade those projects to the latest version, to check it out.
The easy part
Upgrading React was in fact the easy part … Since my app was react-warnings free, as said on the upgrade-guide, I only had to:
- switch to
react-dom/serverfor the server-side). As of now the render engine is a different module (React already did the render on browser and server, but now that there is react-native, it really makes sense to split)
- switch to
react-addons-*modules and drop
React.addonswhich were deprecated (more modularity)
The tricky part
I was using
firstname.lastname@example.org and by upgrading to
email@example.com, I ran into invalid peerDependencies problem (
firstname.lastname@example.org couldn’t work with a version of React over 0.13).
But for the server-side, I hit an issue: on previous versions, you could attach pretty much any attribute to the object passed from the router to your components. Now if you do that, it won’t get all the way down to your components. The workaround I finally found is to attach those data to the params attribute of the object passed by the router and retrieve them in the
props.params of the component … There might be a better way (the createElement API …)
UPDATE: Since then, react-router has released the v0.13.4 which is compatible with
email@example.com, but I’m glad I did the upgrade, so now I have a client & a server-side project that work with the latest versions of React & react-router!
I refactored some components with the syntax introduced in
firstname.lastname@example.org for stateless functional components using ES6 fat arrow (no
class or anything alike).
As I was at it, I enhanced the build routines:
- I added banners on html/js/css containing description/version/git revision (something I’m doing by default now on my projects) – for those who are building their project on heroku, check this commit 😉
- I fixed react-hot-reload for the client-side project (this is a great workflow)
- I fixed livereloading for the server-side project (when you make changes on a component in development, not only your browser has to reload but your also has your node server, since there is server-side rendering and they both need to have the same version)
This sprint was a great exercise to get back into React – both client and server-side. I also got to play with webpack and gulp (yeah, I enjoy setting up build routines 🙂 ). But moreover, coding in ES6 is great … I enjoy it, I did it on my previous project and please, don’t get left behind, don’t fear webpack/Babel, those are great tools that you could easily setup via a yeoman generator or a boilerplate from git …
I’ll keep using React, I do like this library. My next steps will be to add some animation/transition and setting up redux (or a flux-like implementation).
All the code is available on github, each tag has its own release providing a changelog with a list of items pointing to the commits of the version, so if you want to take a peak, please do.