ErrorBoundary Class — react Architecture
Architecture documentation for the ErrorBoundary class in index.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD 2423e1ea_edaa_6c8c_9ebd_17041df87a9f["ErrorBoundary"] 81bda781_d1ab_04a2_f9a5_679111cfc7c2["index.js"] 2423e1ea_edaa_6c8c_9ebd_17041df87a9f -->|defined in| 81bda781_d1ab_04a2_f9a5_679111cfc7c2 0fbbdc9e_c82f_e4ba_03b2_26754a45bd2a["componentDidCatch()"] 2423e1ea_edaa_6c8c_9ebd_17041df87a9f -->|method| 0fbbdc9e_c82f_e4ba_03b2_26754a45bd2a bb48da2e_3380_fd3c_897e_11b1143ab4a5["render()"] 2423e1ea_edaa_6c8c_9ebd_17041df87a9f -->|method| bb48da2e_3380_fd3c_897e_11b1143ab4a5
Relationship Graph
Source Code
fixtures/dom/src/components/fixtures/error-handling/index.js lines 21–53
class ErrorBoundary extends React.Component {
static defaultProps = {
buttonText: 'Trigger error',
badChildType: BadRender,
};
state = {
shouldThrow: false,
didThrow: false,
error: null,
};
componentDidCatch(error) {
this.setState({error, didThrow: true});
}
triggerError = () => {
this.setState({
shouldThrow: true,
});
};
render() {
if (this.state.didThrow) {
if (this.state.error) {
return <p>Captured an error: {this.state.error.message}</p>;
} else {
return <p>Captured an error: {String(this.state.error)}</p>;
}
}
if (this.state.shouldThrow) {
const BadChild = this.props.badChildType;
return <BadChild doThrow={this.props.doThrow} />;
}
return <button onClick={this.triggerError}>{this.props.buttonText}</button>;
}
}
Domain
Source
Frequently Asked Questions
What is the ErrorBoundary class?
ErrorBoundary is a class in the react codebase, defined in fixtures/dom/src/components/fixtures/error-handling/index.js.
Where is ErrorBoundary defined?
ErrorBoundary is defined in fixtures/dom/src/components/fixtures/error-handling/index.js at line 21.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free