Why I switched from EJS to React!
React is here, to make your experience of UI building painless and time-efficient and in a world full of controversies regarding whether to call it a library or a framework, I’d rather term it, a Friend? Just kiddin’. Been with this web stuff for a while, and this shift from a template engine like ejs to framework like react has been quite a thing for me. In this article, I’m gonna share what drove me to make this switch and what I still miss about the former. Now, these are my personal opinions and anyone can impart them differently. Here’s the list,
Speed is all
The first thing about react that captured my attention was the page (almost) never reloads. As a matter of fact, react implements what is called a Single Page Application where everything you write is bundled up into a single HTML file which is constantly being re-written with your components as per the needs of the user and thus presents quite a dynamic view to the audience
More ease with logic
While ejs does allow javascript logics (like else-if conditioning or for loops), the syntax is both cumbersome to write and a pain to read. React introduces the JSX syntax, which while maintaining the proximity to traditional HTML, elucidates the use of programming logic to a great extent. You can render HTML tags in an array map method, ain’t that crazy!
Modularity
Modularity is the cornerstone for the popularity of a tool in a large professional environment, especially when a bulk load of the task is distributed into few teams and is where react strikes in. As said earlier, in react everything is a component, it builds a nice hierarchy where each components render to their respective parents and so on until it reaches the root sitting at the top, often called App.js. EJS also provides such modularity to an extant with its include function but gets stumped owing to the inability of passing any data from the parent to children as react accomplishes with props.
Data flow
The data flow in react is centralized which leads the developer one step ahead in state management and grants more control over the variables. While react itself can manage the state with its context API, it is better provided by a third party state container, like Redux.js. It works in an action-reducer cycle where all the app level data are fetched and accumulated via action functions into a central file, often referred to as the Store, which in turn delivers the data to required components via other action functions. The data flow in react is mostly unidirectional, top to bottom, but sometimes can be compromised to travel in reverse.
The community
Needless to say that the community support for react is more than huge and by that, I’m talking of the ready to use npm packages and components built by millions of developers around the globe, just waiting to be a part of your awesome project. React readymade components apart from being easy to install and fun to adapt, are quite the time and effort savers and let you focus one thing you’re assigned to do. Just type in npm i package_name and the package is yours, forever😍.
Cause it’s trendy to use
I mean, seriously, that’s a cause too😁. It’s quite top on the trend and gives you a little flex, ‘I’m a frontend developer, I code in React 😎’.
About the things I miss in react? Well jQuery tops the list. Like c’mon that cute friendly little library — not that you can’t use jQuery in react but that would be like riding an R15 with the side wheels on!
So that was it, why don’t you share your favourite library/framework! And as always, happy coding.