1 year ago
#259820
ihammerstrom
How to detect if no errors thrown in React Error Boundary?
I'm trying to emit a 0-errors metric when an Error Boundary does not trigger. However, it seems there's nothing like a "componentDidntCatch" lifecycle method, and if I do something like:
public componentDidMount(): void {
if (!this.state.hasError) {
emitZeroErrorMetric()
}
}
it will read the this.state.hasError
as False and emit the metric even if an exception will be thrown, as although the component has mounted, the exception hasn't been thrown yet as part of the child component's rendering.
How can I detect when the child component is done rendering and only check if an uncaught exception has been thrown after it is done rendering?
reactjs
metrics
react-error-boundary
0 Answers
Your Answer