|
Answer» Though we can implement in both functional and class-based way, there are few fundamental differences between the two of them: - Functional component can’t have stated ( before React hooks era ). It renders component only based on props PASSED. A class-based component can have a local state which can be helpful in building a BIGGER component
- Functional component ACCESS directly via props argument passed. In a class-based component, props are accessible via this.props.
- A class-based component is a more complex structure. It is an instance of a class derived from React. Component class. The class must implement a RENDER() member function which returns a React component to be rendered
- The class-based component can also use LIFECYCLE methods but functional component can’t use lifecycle methods.
- Functional components are a very light weighted component in comparison to class-based react component
|