ReactJS

Dilshan U.K.T
5 min readMay 15, 2022

In this blog, I’ll share what I’ve learned about ReactJS as well as what I’ve learned from my own personal experience.

React is a fantastic JavaScript library that allows engineers to compartmentalize their code and edit/add to it more easily as needed. Your code is fragmented and difficult to discover in vanilla JS, for lack of a better description. React allows you to have multiple components, each with its own set of code that only applies to that component, resulting in a much cleaner codebase.

What is ReactJS

ReactJS is a declarative, quick, and flexible JavaScript library for developing reusable UI components. It’s a component-based front-end library that handles the application’s view layer exclusively. Jordan Walke, a software developer at Facebook, produced the concept. Facebook invented and maintained it, and it’s later used in Facebook products like WhatsApp and Instagram. Although it was originally released to the public in May 2013, Facebook invented ReactJS in 2011 for their newsfeed area. Most websites currently employ the MVC (model view controller) paradigm. The ‘V’ in MVC architecture stands for view, whereas the architecture is provided by Redux or Flux.

A ReactJS application is made up of numerous components, each of which oversees producing a small, reusable HTML chevalier. Components are the foundation of all React programs. These components can be built on top of one another to construct complex applications out of simple components. ReactJS uses a virtual DOM-based approach to populate data in the HTML DOM. Because the virtual DOM alters individual DOM elements rather than reloading the entire DOM, it is fast.

To create a React app, we create React components that correspond to various aspects. Higher-level components organize these components, which establish the application’s structure. Consider a form that contains numerous elements like as input fields, labels, and buttons. Each form element may be written as a React component, which we then combine to produce the form component itself. The form components would describe both the structure and the pieces of the shape.

Why is ReactJS

  • Easy production of dynamic online apps - React makes it easier to create dynamic web applications by requiring less coding and providing more functionality, as opposed to JavaScript, which can quickly become difficult.
  • React leverages Virtual DOM, which speeds up the development of online apps. Instead of updating all the components again, as traditional web applications do, Virtual DOM examines the components’ prior states and updates only the objects in the Real DOM that have changed.
  • Reusable components - Components are the fundamental building pieces of every React application, and most apps have numerous components. These components have their own logic and controls, and they may be reused across the program, reducing the development time significantly.
  • Unidirectional data flow - The data flow in React is unidirectional. As a result, developers frequently nest child components within parent components when creating React apps. Because data flows in a single path, debugging faults and determining where a problem arises in an application at any given time becomes easier.
  • Small learning curve - React is simple to understand since it mixes basic HTML and JavaScript concepts with some useful enhancements. Still, like with other technologies and frameworks, you’ll need to devote some time to learning React’s library thoroughly.
  • It may be used to create both web and mobile applications: React is well-known for its usage in the creation of web applications, but that’s not all it can do. React Native is a popular framework for building stunning mobile apps that is derived on React itself. React may therefore be used to create both web and mobile applications.

React Features

  1. JSX.
  2. Components.

3. One-way Data Binding.

4. Virtual DOM.

5. Simplicity.

6. Performance.

JSX - The acronym JSX stands for JavaScript XML. It’s a JavaScript syntactic extension. The syntax of ReactJS is XML or HTML-like. This syntax is transformed into JavaScript calls in the React Framework. It extends ES6 to allow HTML-like text to coexist with JavaScript react code. It is not necessary to use JSX, however it is strongly recommended in ReactJS.

Components - ReactJS is built around components. A ReactJS app is made up of multiple components, each with its own logic and controls. These components are reusable, making it easier to maintain a clean code base while working on larger projects.

One-way Data Binding - ReactJS is designed to handle one-way data binding, or unidirectional data flow. One-way data binding allows you to have more control over your application. Additional features are necessary if the data flow is in the other direction. This is the case because components are supposed to be immutable, and the data they contain cannot be changed. Flux is a design that helps unidirectional data flow. This improves efficiency by broadening the application’s capabilities.

Virtual DOM - A virtual DOM object represents the original DOM object. It works in the same way as a one-way data binding. Whenever the web application is changed, the entire UI is re-rendered in virtual DOM representation. The old DOM representation is then compared to the new DOM representation. After that, only the elements that have changed will be updated by the true DOM. This improves application performance and reduces memory waste.

Simplicity - ReactJS uses a JSX file to make the application simple to design and understand. Because ReactJS is a component-based framework, the code can be reused as needed. This makes it simple to use and comprehend.

Performance - The speed of ReactJS is well-known. This distinguishes it from other frameworks currently available. This is because it oversees a virtual DOM. The Document Object Model (DOM) is an HTML, XML, and XHTML cross-platform computer programming API. The DOM is entirely reliant on memory. As a result, when constructing a component, we didn’t write straight to the DOM. We’ll instead develop virtual components that will be transformed into the DOM, resulting in smoother and faster performance.

Advantages of ReactJS

  • More freedom in reusing previously written code.
  • When the functional component becomes more complicated, there is no need to modify it into a class component.
  • You do not need to be concerned about this.
  • Methods are no longer bound.
  • Hooks make it easier to distinguish between logic and user interface.

Disadvantage of ReactJS

  • Lack of Documentation.
  • JSX as a barrier
  • It covers only UI hence we need to use other languages to make a full application.
  • The high pace of development makes developer life difficult.

Please add your comments if you enjoyed this article too 👍.

--

--