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 boundaries of the application.Unlike the getDerivedStateFromError method, this method is called during the commit phase, so side-effects are also allowed in this method.SyntaxcomponentDidCatch(err, data)Parameterserr - Error thrown by the component.data - Stores information about the component which has thrown the error.ExampleIn this example, we will build a React application that displays the ... Read More
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' keyword is used to pass the reference to that function while the second parameter is passed as arguments to the function.ExampleIn this example, we will build a React application that passes the arguments to a function when a button is clicked.App.jsximport React from 'react'; class App extends React.Component { ... Read More
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 status code for every response that is being received.ExampleIn this example, we will build a React application that automatically checks and logs the status code that is sent by the server while sending a POST request from our React application.We have to set all the configuration in the most global ... Read More
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 React application without React Fragments.ExampleApp.jsximport React from 'react'; class App extends React.Component { render() { return ( TutorialsPoint Simply Easy Learning ... Read More
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 time when the props passed to it changes or its parent component re-renders.Our first component in the following example is App. This component is the parent of the Comp1 component. We are creating Comp1 separately and just adding it inside the JSX tree in our App component. Only the App ... Read More
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 used to remove the previous useEffect hook’s effect before using this hook of the same component again.SyntaxuseEffect(()=>{ return ()=>{} } ,[]);ExampleIn this example, we will build a React application which displays the coordinates of the mouse pointer when it is moved over the screen. For this to implement, we ... Read More
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 the technique used to speed up the application by storing the result as the cache and only calling the function again when the inputs are changed otherwise the cached result is returned.Use React.memo() for functional components. This method is used to only re-render the component if the props passed to ... Read More
What is Scalability Testing and Learn with ExampleA system/application must have the capability to function flawlessly under excessive load. Scalability testing features the process where the efficiency of a system is tested based on a growing number of user requests, data volume, transactions, and user traffic. The developers identify the points where the system stops responding to changes and dig deeper to find its reasons.Salient features of Scalability TestingIt tells you how the application behaves under heavy loadIt let you know the limitation of the app in terms of user experienceIt helps you determine the efficiency and limits of the ... Read More
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 source code at once, even those pages which are rarely visited by the user. So, to prevent the entire loading of the application at once, we use the concept of lazy loading to decrease the DOM load time and to increase the speed of the application.Syntaxconst OtherComponent = React.lazy(() => ... Read More
Cybercriminals use numerous ways to take advantage of the vulnerabilities in the operating system or applications to infiltrate the device or network. One such method is using the Backdoor Attack.In this post, we would discuss what Backdoor Attack is, its types, and how to stay safe from Backdoor Attacks.What is a Backdoor Attack?In cybersecurity terms, a Backdoor Attack is an attempt to infiltrate a system or a network by maliciously taking advantage of software's weak point.Backdoors allow the attackers to quietly get into the system by deceiving the security protocols and gain administrative access. It is similar to the real-life ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP