Web / ReactJS Interview questions
What is 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 the component tree that crashed. Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.
Error boundaries do not catch errors for: Event handlers, Asynchronous code, Server Side Rendering (SSR), and Errors thrown in the error boundary itself (rather than its children).
Error boundaries work like a JavaScript catch {} block, but for components. Only class components can be error boundaries.
More Related questions...