React is cool, deal with it

Everybody knows how crazy javascript world has been lately releasing new tools faster than you can learn them, there’s one tool, React that markets itself as the V in MVC ( or at least it used to ) that slowly started to take over front-end development, yet still i read about many people complaining with wrong arguments about why they don’t like it so i decided to talk about what is it that is so great about react.

So what is react? According to their page it is a “javascript library for building user interfaces” and it was developed by Facebook to solve the mess they were having with scaling front-end development. It is very lightweight, yes that means that it does not come with many built-in functionalities like other frameworks, so what’s the cool thing? It makes you think in terms of components and develop them in a declarative way.

With react you don’t write HTML, they implemented JSX which is a processor that lets you add xml style tags in javascript so instead of having a separate file for your scripts you write both the logic and the content in a single file. This seems crazy at first, but this results in much cleaner code.

Let’s say you want to list properties on a table fetched from API. If you were developing following MVC pattern you would first implement a Model which would represent the property and implement any related activity of API communication in that layer, add a route to a controller which would fetch the model and pass it to the view. We’re talking about three different files to fetch and display in a table in contrast to simply develop a “PropertyList” component and all related logic there. This makes it much easier to reason about your code and scale as you can treat anything as just a component and your application as a bunch of components interacting.

React is hard to learn, we’re all used to seeing javascript and html in different files, we’re all used to MVC and it lacks much functionality so you need to add some different things to handle routing, api calls, jsx support, etc.. which is why people don’t actually give react a try.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.