Error boundaries catch errors thrown during rendering, in lifecycle methods, and in constructors below them, then render a fallback instead of unmounting the whole app. They are still class components using getDerivedStateFromError and componentDidCatch, or a wrapper library. They do not catch errors in event handlers, async callbacks or the boundary itself, so those need ordinary try and catch plus reporting.
Why interviewers ask this
The interviewer wants to know if your apps degrade gracefully or blank out. They are listening for the precise scope of what boundaries catch, since the gaps (event handlers and promises) are exactly where production errors happen. Placement matters too: a single boundary at the root is barely better than nothing, and a good answer talks about isolating risky regions and giving users a way to recover.
How to structure your answer
- State what boundaries catch and what they render instead.
- Name the gaps clearly: handlers, async, server rendering.
- Describe where you place boundaries in a real layout.
- Cover reporting and giving the user a recovery path.
Example answer
Error boundaries catch anything thrown while rendering the subtree beneath them, and swap in a fallback so one broken widget does not take down the page. I usually use the react-error-boundary wrapper rather than writing the class myself, since it gives me a reset handler for free. The gaps are the part people forget: nothing thrown in an onClick, a setTimeout, or an unhandled promise rejection reaches a boundary, so those still need try and catch with an explicit error state. On placement, one boundary at the root is basically a nicer crash screen. What I actually do is wrap each independently useful region, so the sidebar, the main panel, and any third party embed each have their own, with a fallback that says what failed and offers a retry that resets the boundary and refetches. Every boundary reports to our error tracker with component stack and user context in componentDidCatch, and in React 19 I also set onUncaughtError at the root so nothing slips through unlogged.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- Where exactly would you place boundaries in a dashboard layout?
- What catches an error thrown inside a promise in an event handler?
- How do error boundaries behave during server rendering and hydration?
Related react developer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions