Skip to content

Commit 7763743

Browse files
committed
Wrap console.error with is-development conditional
1 parent 111eb8a commit 7763743

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/ErrorBoundary.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { isDevelopment } from "#is-development";
12
import { Component, createElement, ErrorInfo, isValidElement } from "react";
23
import { ErrorBoundaryContext } from "./ErrorBoundaryContext";
34
import { ErrorBoundaryProps, FallbackProps } from "./types";
@@ -88,9 +89,12 @@ export class ErrorBoundary extends Component<
8889
} else if (FallbackComponent) {
8990
childToRender = createElement(FallbackComponent, props);
9091
} else {
91-
console.error(
92-
"react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop"
93-
);
92+
if (isDevelopment) {
93+
console.error(
94+
"react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop"
95+
);
96+
}
97+
9498
throw error;
9599
}
96100
}

0 commit comments

Comments
 (0)