What is React Js ?
Let's understand in simple words what “react” means. The general meaning of “react” is 'to do or say something because of something that has happened'.
ReactJS is just like the same. In simple words, “react” in the context of ReactJS means to update or change part of the web page or user interface in response to something that has happened, such as a user clicking a button, entering the data in the form, or getting new information from the server, etc.
In everyday life, when something happens, we react to it. For example, if we are in a classroom and the teacher asks a question, we respond with an answer. Similarly, in web development, ReactJS helps developers build web-based applications that react to user actions or data changes. When users interact with a React-powered web application, it dynamically updates the user interface to show new information or reflect the user's input without needing to reload the entire page.
Now, you are thinking about how the information on the page update without reloading the page. Here comes the concept of “Virtual DOM” We are understanding it more in this.
React accomplishes this by using a virtual representation of the user interface called the “Virtual DOM”. Whenever there's a change, React efficiently compares the Virtual DOM with the Actual DOM, and only updates the parts that need to be changed. This makes the application process faster and more efficient, leading to a smoother and more interactive user experience.
Now it's time for describing the definition of ReactJS,
ReactJS is an open-source JavaScript library that is developed and maintained by Facebook. It was first released in 2013 and has since gained massive popularity in the web development community.
React is primarily used for building user interfaces (UI) also referred to as a front-end or client-side library.
Why we use ReactJs ?
One of the main reasons why we use ReactJS is because of “its potential to reuse code as components”.
If you don't know what are components no worries we will understand them later, for now just remember “It's a piece of code we can use again and again in our application”.
Key features of ReactJS
Component-Based Architecture: React follows a component-based architecture, where the code is divided into reusable components. Each component works with its own logic and state, making it easier to manage and maintain the code.
Virtual DOM: React uses virtual DOM to enhance its performance (Virtual DOM is a lightweight copy of the actual DOM). Instead of directly manipulating the actual DOM, React uses a Virtual DOM compares it with the React DOM, and updates only the necessary parts. Due to this, the number of actual DOM manipulations reduces, which leads to better performance.
JSX (JavaScript XML): React uses JSX, an XML-like syntax extension to JavaScript, to describe the UI component's structure. JSX allows you to write HTML-like code in a JavaScript file with the file extension .jsx (example:- Suppose you have a file name called "Profile" where you are working with profile-related information then in react you create this file as Profile.jsx or Profile.js, which makes this more flexible to work with both JavaScript and HTML at the same time.
There are more features of React. We will cover all in this post, so no worries.
Next question which came in your mind is Why we use React ?
Easy to Learn: Let's understand with a scenario, suppose you have an HTML file called hello.html to change anything dynamically you have to write JavaScript code whether in <script> tag or to use a separate file with a .js extension then call it using a script tag in HTML. So, in ReactJS, there is no need to do this, we simply have to write our in components.
In ReactJS, we simply write it like this
import React from "react";
export const hello = () => {
return <div>hello world</div>;
};
Output:- hello world
Reusable Components: React allows you to create reusable UI components, which helps in calling the same components on different pages wherever it is required, and saves time and effort in developing the same components again. For Example, You are creating a movies API web app, and you have 2 pages on 1st page you are showing trending movies and on 2nd page, you are showing search input for searching the movies, for this you have created a card component for movies on which details of the movies are showing. So to call that card component on different pages, you don't have to write card code again. You have to just call the card component on that page, and you are good to go.
Unidirectional Data Flow: Rect follows a unidirectional data flow, which means data flows in a single direction, from parent components to child components. This makes it easier to understand how data changes in the application, making it easier to debug and test the application faster.
Fast Rendering: When developing a complex, high-loaded web app, it is essential to define the structure of the app at the beginning as it can greatly influence your web app's performance. To solve that issue, React uses Virtual DOM, which helps in comparing the Virtual DOM with the Real DOM and makes the necessary updates accordingly.
Proficient Data Binding: As the data flows in one direction, it is easy to track and bind the data effectively to a particular portion of the component.
Comments
Post a Comment