Rahul Bansal has Published 50 Articles

ReactJS – componentDidMount Method

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:38:36

798 Views

In this article, we are going to see how to execute a function when the component is loaded in the DOM tree.This method is majorly used during the mounting phase of the React lifecycle to handle all the network requests or to set up all the major subscriptions of the ... Read More

ReactJS componentDidCatch method

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:34:31

977 Views

In this article, we are going to see how to execute a function in the commit phase if some error occurs in the Component.This method is called when a component or any children component encounters some error during the React Component Lifecycle. This method allows us to handle the error ... Read More

ReactJS – bind() method

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:31:09

4K+ Views

In this article, we are going to see how to pass arguments to a function in a React applicationReact has a predefined bind() method which we can use to pass the arguments to a function in the class based components.Syntaxthis.func.bind(this, [args...])It accepts two parameters, this keyword and the arguments. 'this' ... Read More

ReactJS – Axios Interceptors

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:29:48

10K+ Views

In this article, we are going to learn how to intercept every request or response that is being sent by Axios Interceptors in a React application.Axios interceptors are the default configurations that are added automatically to every request or response that a user receives. It is useful to check response ... Read More

ReactJS – Fragments

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:23:38

309 Views

While building a ReactJS application, all the JSX code needed to be wrapped down inside a parent tag.ReactJS Fragments were introduced with React 16.2 version to remove the need to define an extra tag which also takes extra memory.Without FragmentsThe following sample code shows how to create a simple ... Read More

ReactJS – Component vs PureComponent

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:22:17

1K+ Views

In this article, we are going to see the difference between Component and PureComponent. In ReactJS, Components are widely used to make an App more efficient and effective to use.ReactJS provides two different ways to use components – Component or PureComponent.ComponentIt is the type of component which re-renders itself every ... Read More

ReactJS – Cleaning up with useEffect hook

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:20:13

585 Views

In this article, we are going to see how to clean up the subscriptions set up in the useEffect hook in the functional component.Once the effects are created, then they are needed to be cleaned up before the component gets removed from the DOM. For this, cleaning up effect is ... Read More

Optimizing ReactJS applications

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:10:34

152 Views

In this article, we are going to see the methods to optimize our React application.To create a real-world React application, optimized code is greatly required to enhance the performance. There are several ways to optimize a React application but some of the most preferred ways are mentioned below −MemoizationIt is ... Read More

Lazy Loading in ReactJS

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:05:31

4K+ Views

In this article, we will learn how to lazily load the pages of our application to make our React application more optimized.React apps are bundled with the preinstalled bundlers like webpack before making the React application to be production ready. When this bundled project is loaded, it loads the whole ... Read More

Import Files and Images in ReactJS

Rahul Bansal

Rahul Bansal

Updated on 18-Mar-2021 11:01:08

4K+ Views

In this article, we are going to see how to import CSS Files, images and functions defined in other folder to the main App.js file.In React, we need to dynamically import the images from their folder.ExampleIn this example, we will define a project structure with the images and components already ... Read More

Advertisements