File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
packages/react-debug-tools/src Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -18,13 +18,10 @@ export const ErrorsNames = {
18
18
UNSUPPORTTED_FEATURE_ERROR : 'UnsupportedFeatureError' ,
19
19
} ;
20
20
21
- export function UnsupportedFeatureError ( message : string = "" ) {
22
- // Make this an instanceof Error.
23
- this . constructor . prototype . __proto__ = Error . prototype ;
24
-
25
- this . name = ErrorsNames . UNSUPPORTTED_FEATURE_ERROR ;
26
- this . message = message ;
27
- if ( Error . captureStackTrace ) { // only available in V8
28
- Error . captureStackTrace ( this , this . constructor ) ;
29
- }
21
+ // For now we just override the name. If we decide to move react-debug-tools to
22
+ // devtools package, we should use a real Error class instead.
23
+ export function createUnsupportedFeatureError ( message : string = "" ) {
24
+ const error = new Error ( message ) ;
25
+ error . name = ErrorsNames . UNSUPPORTTED_FEATURE_ERROR ;
26
+ return error ;
30
27
}
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import {
29
29
ContextProvider ,
30
30
ForwardRef ,
31
31
} from 'react-reconciler/src/ReactWorkTags' ;
32
- import { UnsupportedFeatureError } from './ReactDebugCustomErrors' ;
32
+ import { createUnsupportedFeatureError } from './ReactDebugCustomErrors' ;
33
33
34
34
type CurrentDispatcherRef = typeof ReactSharedInternals . ReactCurrentDispatcher ;
35
35
@@ -364,7 +364,7 @@ const DispatcherProxyHandler = {
364
364
if ( target . hasOwnProperty ( prop ) ) {
365
365
return Reflect . get ( ...arguments ) ;
366
366
}
367
- throw new UnsupportedFeatureError ('Missing method in Dispatcher: ' + prop);
367
+ throw createUnsupportedFeatureError ('Missing method in Dispatcher: ' + prop);
368
368
} ,
369
369
} ;
370
370
You can’t perform that action at this time.
0 commit comments