Why React?
I will try to explain the reasons I chose React over other JS libraries and frameworks as the one I wanna spend significant time learning.
React’s simpleness
Please take a look at the following example. It is a simplest component made with React.
As anyone can see this is absolutely clean and simple code!!
Component based architecture
Ok, this should have been first because we already used one component above. Components in general are snippets of reusable and self-contained code. You can imagine a component like an HTML element. They are the building blocks of your application. And like building blocks are well-defined and reusable. You can make a wall with bricks, then tear down this wall and build a fireplace, anything that can use bricks as elements. I think you catch the drift!! And this leads us to…
Productivity, efficiency and perfomance
Code reuse, readability and cleanliness are the foundation of software productivity. Always were… Talking about efficiency reminds me of the Virtual DOM. You see when React loads a page it creates a virtual representation of the actual DOM. Then when something changes React calculates what needs to be changed and changes ONLY this. It uses diff algorithms for this kind of calculations from what I have read so far. You can read more about this in the official docs. As a result of all these perfomance is great.
React uses JSX and ES6
See here… The thing is that React is the future of web development because it has embraced all the “next” big things. With polyfills like Babel you can use ES6 extremely powerful new tools now. And this is very important thing!! JSX is a syntax extension to JavaScript which enables you to write virtually the same HTML inside JS!! Awesome stuff!!
PS: you saw some JSX in the HelloWorld component!
React is great with SEO
React has the ability to be rendered on the server a thing that let’s say compared to Angular, rocks!! Once I used Angular for an SPA and ultimately fell in the SEO trap: how on earth I can render the JS inside the meta tags so services like social networks and search engines will read the tags properly and not something like {{}}???
I stumbled then on things like “make a custom php file and redirect the bots there”, use Prerender.io, use PhantomJS to take snapshots etc. etc. Dear Lord!!
React has an extension for Chrome developer tools
It makes app development a breeze!! More on this on a future article.
GREATEST THING: React has a Native mobile extension
Look at the same example written as a mobile app!! Oh man!! This is what I’ve been looking for…
You can include even Java or Swift inside your components, but this is a topic of a future article, of course.