Q37: What is React.cloneElement and why is it increasingly discouraged?

React.cloneElement() creates a clone of a React element while merging new props into it. It is discouraged in modern React because it makes prop sources implicit and hard to trace compared to render props or context.

Key Takeaways
  • Clones a React element and injects additional props.
  • Discouraged in favor of component composition or Context patterns due to fragile prop overriding.
Knowledge Check

Which modern design pattern is widely preferred over React.cloneElement?