Skip to main content
InterviewHubPRO
Section Overview
Q175

Question 175 of 407

Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

43%
React Core & Hooks (407 Qs)•Part 8: Advanced React Patterns, Portals & Performance (152 - 261)

What is the benefit of component stack trace from error boundary?

junior LevelCode ExampleComponentsFormsPerformance

Apart from error messages and javascript stack, React16 will display the component stack trace with file names and line numbers using error boundary concept.

For example, BuggyCounter component displays the component stack trace as below,

stacktrace
stacktrace

Practical Code Example

text
// Component Stack Trace from Error Boundary identifies the exact JSX component tree hierarchy
// pointing directly to the offending file and line number:
// in BrokenComponent (at App.js:14)
// in ErrorBoundary (at App.js:12)
// in div (at App.js:10)