fix: Remove the onRenderError prop and add an ErrorBoundary component

This commit is contained in:
Johannes Schill
2019-01-08 13:32:08 +01:00
parent bcb94cc0ec
commit f428db282c
6 changed files with 71 additions and 19 deletions

View File

@@ -9,7 +9,6 @@ export interface PanelProps<T = any> {
renderCounter: number;
width: number;
height: number;
onRenderError: () => void;
}
export interface PanelOptionsProps<T = any> {

View File

@@ -13,7 +13,6 @@ interface GraphProps {
showBars?: boolean;
width: number;
height: number;
onRenderError: () => void;
}
export class Graph extends PureComponent<GraphProps> {
@@ -38,7 +37,7 @@ export class Graph extends PureComponent<GraphProps> {
return;
}
const { width, timeSeries, timeRange, showLines, showBars, showPoints, onRenderError } = this.props;
const { width, timeSeries, timeRange, showLines, showBars, showPoints } = this.props;
if (!width) {
return;
@@ -99,7 +98,7 @@ export class Graph extends PureComponent<GraphProps> {
$.plot(this.element, timeSeries, flotOptions);
} catch (err) {
console.log('Graph rendering error', err, flotOptions, timeSeries);
onRenderError();
throw new Error('Error rendering panel');
}
}