Category Archives: JavaScript

7 reasons React is the best front-end framework to use

React is a great tool for building user-friendly interfaces quickly. It is JavaScript-based library for building dynamic web components. Facebook created React more than 10 years ago. It was primarily used to manage news feed. Thanks to React, users are able to see changes – new comments, posts, notifications – without refreshing the page.

In this article, we will discuss React and practical reasons behind its popularity.

Simplicity

React is very simple to learn. Its templating language JSX looks just like HTML. The process of building user interfaces with React is very similar to building static websites in HTML. Despite similarities between the two, JSX allows you to implement dynamic features more easily.

To embed JavaScript expressions in React applications, you need to wrap them with a pair of curly braces. That way, JSX knows how to interpret JavaScript expressions.

Easy to start

Basics of React are really easy to learn. Advanced concepts take some time, but you can learn basics to create a simple web application in one day.

Because of its popularity, there are plenty of free tutorials for building web apps in React. Documentation for basic concepts is quite good and often updated.

Ability to reuse code

Like other front-end frameworks, React allows you to create components to represent one small visual or functionality of your website. Then you can reuse these components with different bits of data. You can use props to ‘feed’ specific data to the component, and fill the contents of that component with that data. For example, a design of an individual to-do task will be the same. But contents of it will be different. You can iterate over an array of objects in React and use data in each object to create new <Todo> components.

Supporting libraries

React is a popular library, so there are a lot of supporting utilities and libraries. These help React developers implement common features without manually doing it. For example, there’s a react-select library that provides a ready component for implementing select elements in React. As you can see in this article, setting a default value for react-select is much easier than it is for standard select elements.

Virtual DOM

This is one of the main React features. It allows React to display updates without refreshing the page. Whenever state or prop values change, virtual DOM will be updated to reflect those changes. React then compares virtual and actual DOM models and settles differences between them.

The entire React ecosystem (virtual DOM, state, props) allows you to design web apps with great user experience. Add features like scroll to bottom of the page when user clicks a button. Learn about how to do that here – https://simplefrontend.com/react-scroll-to-bottom/.

SEO-friendly

Despite what you might’ve heard, React can be quite SEO-friendly. Single Page Applications are entirely rendered in client browser, so they are not SEO friendly. However, there are plenty of services and technologies that allow you to use React with static site generators, or even for server-side applications. In these cases, you get the best of both worlds – React’s speed coupled with the SEO benefits and stability of static websites.

Community

There are a lot of experienced React developers out there. If you’re going to ask something on platforms like StackOverflow, experts are there to help you. There are also plenty of online guides posted about React and its features.

Advantages and Disadvantages of React

As of right now, front-end community has fully embraced React. Still, there are a lot of developers who consciously decide against using React and choose Vue, Angular, or even Svelte. This is not to say that React is not useful. It is in fact the best tool for building interactive interfaces right now. I wanted to dedicate this article to breaking down advantages and disadvantages of React.

Advantages

Easy to figure out

There’s a wealth of information available about React and its practical use cases. Official documentation is well written. In addition to that, there are plenty of video tutorials. Most important React concepts are based on JavaScript. So, if you’re someone who understands JavaScript well, then you can figure out React within few months or even weeks.

Reusable components

React saves you from having to write the same code over and over again. Certain parts of a website usually follow the same pattern and organization. For example, blog posts are all designed the same way and they have the same structure. The only different thing between blog posts is their content – title, text, and so on.

React web apps are like component trees. The same parent component can have many child components of the same type. You create a component once and you can reuse it as many times as you want. Certain components are made up of other components. State and props allow you to maintain data and pass it into child components if necessary.

Virtual DOM

React implements a virtual DOM. This is one integral feature that makes React extremely fast. Virtual DOM is a shadow image of the real DOM. Whenever there are changes in the virtual DOM, React synchronizes virtual and real DOMs and updates it efficiently.

Search Engine Friendly

You can use various static site generators to host your React web app. This way, search engines will be able to index contents on your page. Purely client-based applications can not be indexed in search engines.

Supporting libraries

React is a popular front-end framework with a large community of developers. Naturally, these developers have created a variety of useful packages and libraries for implementing certain features necessary for web development. For example, use form libraries for validation or to clear form after submit.

Disadvantages

Fast pace of updates

React is constantly evolving. Any web developer who wants to build web apps in React needs to stay up to date to changes. For example, React v16.8 brought a lot of changes. It introduced hooks in functional components. This change alone turned a lot of React world upside down.

Sometimes documentation updates are slow and do not follow immediately.

Only a library

Many people mistakenly call React a front-end framework. Actually, React is only a library. It deals with presentational part of the application. It does not have built-in solutions for routing or advanced state management. However, there are many supporting libraries like react-router and redux that help.

JSX

For me personally, JSX is an advantage. It allows you to embed JavaScript expression in the structure. This allows you to create dynamic interfaces. However, there’s definitely a learning curve. Many beginners struggle with rules of JSX. SimpleFrontEnd has excellent guides on how to implement common dynamic features using JSX.