What Is React Js?

Published On

January 16, 2024


Ankur Srivastava




ReactJS is a free open source JavaScript library. It is especially used to create user interface of single page applications. ReactJS is a front-end JavaScript framework developed by Facebook and released in 2011 by Jordan Walke of Facebook. React allows us to create reusable UI components.

Why use React Js?

  • Component : Based Architecture: Encourages modular and reusable code through components, making development and maintenance more efficient
  • Virtual DOM: Optimizes rendering by updating only changed parts of the DOM, improving performance and user experience.
  • Declarative Syntax: Offers a straightforward way to express UI logic, enhancing code readability and maintainability.
  • Efficient State Management: Facilitates unidirectional data flow, simplifying state management and reducing bugs.

Advantage of React Js?

  • With the help of React, a dynamic application can be created very easily because React provides more functionality in less coding due to which a better application can be created in less time. React Virtual DOM is used due to which the web is created faster.
  • In React, components of each object or section are created which are reused later. Due to this, the development of a web application can be faster.
  • It is easy to debug errors because the flow of data in the response is unidirectional, so it can be detected in real time where or what the error is.
  • React is used to create both web applications and mobile applications. You can create a web application with react and you can create a mobile application with react native.
[What is React? | Web Tutorial Hindi](https://webtutorialhindi.com/react-kya-hai/)

What is React Router ?

Routing refers to the process of navigating between different pages without triggering a full page reload. The application initially loads a single HTML page. Then, it dynamically renders different components based on user interaction. Since React does not have built-in routing capabilities, you need to implement it using a third-party library.

[How to Build a Routing Layer in React and Why You Need it](https://semaphoreci.com/blog/routing-layer-react#:~:text=In%20a%20single%2Dpage%20React,components%20based%20on%20user%20interaction)

What is a routing layer?

A routing layer is the part of a frontend React application responsible for managing paths and rendering the appropriate page components. When a user clicks on a link or enters a URL in the address bar, the routing layer intercepts the request and determines which component or view should be rendered based on the current path.

[How to Build a Routing Layer in React and Why You Need It - Semaphore . ](https://semaphoreci.com/blog/routing-layer-react#:~:text=In%20a%20single%2Dpage%20React,components%20based%20on%20user%20interaction)

React-Router-DOM ChatGPT

react-router-dom is a React library that facilitates client-side routing in web applications. It provides components like BrowserRouter, Route, and Link for creating navigation and rendering different components based on the URL. This enables the development of single-page applications with dynamic content, enhancing the user experience by avoiding full-page reloads during navigation.

What is difference between react-router-DOM and react-router?

react-router and react-router-dom are both part of the React Router library, and they share much of the same functionality. However, there is a key difference:


  • This is the core package of React Router.
  • It provides the fundamental routing components and functionality.
  • It doesn't include any dependencies on a specific DOM (Document Object Model) implementation.
  • It's suitable for React Native or other non-DOM environments.
  • if you are building a mobile application you might use react-router.

  • This package builds on top of react-router and is specifically designed for web applications using a DOM environment.
  • It includes additional features and components that are specific to web applications, like BrowserRouter, Link, and NavLink.
  • It has dependencies on the DOM.
  • if you are building a web application, you will typically use react-router-dom.

React Elements

The React.js element is a fundamental building block that represents the UI in React applications. This is a virtual representation that describes UI components. React elements are JavaScript objects that describe what type of content is shown in the UI. Elements uses JSX syntax. These elements are rendered in the React DOM tree, which updates the UI.

React Components

  • A React component is a reusable piece of UI (User Interface) that is independent and represents a specific functionality or view. JSX (JavaScript XML) syntax is used while developing components.
  • React components can be combined with other components to create complex UIs. Components have the advantages of reusability and maintainability, which allows the code to be managed easily.

Two Types of React Components

  • Functional Components : These are simple functions which take props as input and render the UI. Hooks are used to manage state and lifecycle features. The user uses the functions component which is simple or easy. Hooks are used to manage state and lifecycle features.
  • Class Components: These are class-based components that extend the React.Component class. They are powerful enough to manage state and use lifecycle methods.

React’s Rendering Process

React rendering is a process in which state changes of a React application are observed and changes are applied to update the UI. Rendering means showing the UI on the screen.

A key concept of React is "Virtual DOM" which optimizes rendering. When the state of a component changes, React first creates a virtual representation of the UI, called Virtual DOM. Only those changes occur in this virtual representation which should occur in the actual DOM.

Then React compares this virtual representation with the actual DOM. By determining the difference, React applies only those changes that are necessary, making the rendering process efficient.

The Render Phase

The render phase is the initial phase of the rendering process. In this phase, the JSX code is converted to a JavaScript representation of what the HTML structure should look like.

It starts from the root component and works its way down, building out a React element tree of what the actual DOM should look like.

Re-rendering follows a similar approach but with a key difference: it creates a new JavaScript representation of the DOM, identifying all the components marked as needing an update. [Understand How Rendering Works in React ](https://www.telerik.com/blogs/understand-how-rendering-works-react)