Skip to main content

What is an error boundary?

Junior React
Quick Answer Error boundaries are class components that catch JavaScript errors thrown by their children during rendering, in lifecycle methods, or in constructors. They prevent the whole app from crashing รขโ‚ฌโ€ instead, they render a fallback UI. You can't use hooks for this; class components with componentDidCatch are required.

Answer

An error boundary catches runtime errors in child components and displays a fallback UI instead of crashing the entire app.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice