Q17: What are Error Boundaries in React?

Error Boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of crashing the entire component tree.

Key Takeaways
  • Error boundaries catch rendering errors in child component subtrees.

  • Must be implemented using class components with componentDidCatch or getDerivedStateFromError.

Knowledge Check

Which lifecycle method makes a class component an Error Boundary?