Posts

Showing posts from May, 2020

Understanding ReactJS lifecycle methods

The React lifecycle method helps us in adding logic during different phases of component rendering. Let us look at the various lifecyle methods of ReactJS and understand when they will be triggered during the component render. Do remember that the below listed lifecycle methods is only applicable to class based components and not for functional components. constructor() This is the first method that is triggered during the component's lifecycle, this method is usually used to initialize state or to make API calls before showing it to the user also note that this method is called only once during the entire lifecycle of the component. render()  This is the most important method of class component. If we fail to write this method react will thrown an error it is a must have method in any class component this method primary purpose is to return the UI or the JSX we plan to render on the browser. This method is triggered after the constructor call and every time there is a c