Problem Statement
How do you handle props in functional vs class components?
Explanation
In functional components, props are received as function arguments. In class components, they are accessed via this.props. Props are read-only in both cases.
Code Solution
SolutionRead Only
// Functional
function Hello(props) { return <p>{props.name}</p>; }
// Class
class Hello extends React.Component { render() { return <p>{this.props.name}</p>; } }