File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change 1
- import { Component , createElement , ErrorInfo , isValidElement } from "react" ;
1
+ import { isDevelopment } from "#is-development" ;
2
+ import {
3
+ Component ,
4
+ createElement ,
5
+ ErrorInfo ,
6
+ isValidElement ,
7
+ PropsWithChildren ,
8
+ PropsWithRef ,
9
+ ReactElement ,
10
+ } from "react" ;
2
11
import { ErrorBoundaryContext } from "./ErrorBoundaryContext" ;
3
12
import { ErrorBoundaryProps , FallbackProps } from "./types" ;
4
13
@@ -10,7 +19,7 @@ const initialState: ErrorBoundaryState = {
10
19
} ;
11
20
12
21
export class ErrorBoundary extends Component <
13
- ErrorBoundaryProps ,
22
+ PropsWithRef < PropsWithChildren < ErrorBoundaryProps > > ,
14
23
ErrorBoundaryState
15
24
> {
16
25
constructor ( props : ErrorBoundaryProps ) {
@@ -88,9 +97,12 @@ export class ErrorBoundary extends Component<
88
97
} else if ( FallbackComponent ) {
89
98
childToRender = createElement ( FallbackComponent , props ) ;
90
99
} else {
91
- console . error (
92
- "react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop"
93
- ) ;
100
+ if ( isDevelopment ) {
101
+ console . error (
102
+ "react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop"
103
+ ) ;
104
+ }
105
+
94
106
throw error ;
95
107
}
96
108
}
You can’t perform that action at this time.
0 commit comments