What is the difference between a Class component and a Functional component in React?
Instruction: Compare and contrast Class components with Functional components in React.
Context: This question checks the candidate's understanding of the two types of components in React and their respective use cases, focusing on the evolving React paradigms.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Function components describe UI with functions and can use Hooks for state, context and synchronization. Class components extend Component, render through a render method, and use instance state and lifecycle methods. React recommends function components for new code while continuing to support classes.
A class can initialize state and bind handlers through class fields, so a handwritten constructor is not mandatory...