Why do we use the Functional component instead of the class base component

Why do we use the Functional component Subham Bhattacharjee 1

Introduction:

In React, we create two types of components: class-based components and functional components. While class-based components older approach but the functional components is new and is gained significant popularity and become the preferred choice for many developers. 

  1. Simplicity and Readability:

Functional components are more straightforward and easier compared to class-based components. The simplicity of functional component is improved the code readability and faster development the application. Functional components use the functional programming style and avoiding the complex class hierarchies like Constructer. 

  1. Reusability:

In functional components we also divided it on smaller, reusable components to build complex UI designs. Also, it allows for the creation of custom hooks and reuse of stateful logic across multiple components. With functional components, it is easier to extract logic into separate functions and reuse them in different parts of the application and make easier the maintainability.

  1. Performance Optimization:

Functional components performance benefits through React memorization feature and the use of React hooks. The React.memo() function can be used to memorize the functional components, preventing unnecessary re-renders when their props remain unchanged. Additionally, react hooks, such as useState, useEffect, useContext, etc. allow us to manage state and lifecycle behaviour in functional components, without the need for class-based lifecycle methods. Hooks enable efficient updates and avoid excessive rendering and optimized the performance of the application.

 In this picture I was store the reusable component in component folder and now if I need some code instead of creating new one, we are using that reusable component. It should be the folder structure. It is an example of Reusability.uG0iWcreFlrQTFuAhuZuZ2B5OAZJiAFPZymwuEnbNvqaD7TPt3mVX2kMgxTOqH MwI SsIPztXZCvjJ 8dR4 1DXkt6M0zNm8bcgkdOfO 7vvomdTw4mbCQ5IiQgQSA0SQMffJN B6XACg bv98u9Q

Conclusion:

The functional components are gaining lots of popularity. The simplicity, reusability, performance benefits etc. is made the preferred choice for many developers. 

AUTHOR-SUBHAM BHATTACHARJEE

Disclaimer: The author(s) of this blog are solely responsible for the content posted. The blog platform serves as a medium for their expression, and the platform administrators assume no liability for the accuracy or legality of the content.
Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!