Lifecycle Methods in Functional components
Sougandika L
Immediate Joiner ll Serving Notice Period ll Software Developer at People Tech Group private Ltd Il ANGULAR l TYPESCRIPT l KENDOUI l NGRX l REDUX l HTML l SCSS I CSS l BOOTSTRAP
Lifecycle refers to the series of phases that a React component goes through from its creation, rendering and eventual removal from DOM.
While the traditional lifecycle methods are allowed for the class components, introduction of hooks has provided the most versatile way to manage behavior of functional components
There are 3 phases in React Component Lifecycle
1. Mounting
2. Updating
3. Unmounting
MOUNTING PHASE:
During Mounting phase component has been created and added to DOM. In this phase State has been initialized.
USESTATE hook allows to add state to your functional components.
UPDATING PHASE:
USEEFFECT hook allows to perform side effects (nothing but the tasks performed outside the component) For example , fetching data from API calls. It eliminates the need of constructor.
UNMOUNTING PHASE:
Unmounting phase, functional component will be removed from DOM.
By returning a function from useEffect hook, cleanup operations can be specified
Understanding the concept of hooks and using them appropriately will result in building efficient React applications.
Thats all about Lifecycle methods in Functional components
Thanks,
Sougandika L.