mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
update per review comments
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file contains a list of custom Errors that ReactDebugTools can throw in
|
||||
* special occasions.
|
||||
* The names of the errors are exported so that other packages (such as DevTools)
|
||||
* can use them to detect and handle them separately.
|
||||
*/
|
||||
|
||||
export const ErrorsNames = {
|
||||
UNSUPPORTTED_FEATURE_ERROR: 'UnsupportedFeatureError',
|
||||
};
|
||||
|
||||
// For now we just override the name. If we decide to move react-debug-tools to
|
||||
// devtools package, we should use a real Error class instead.
|
||||
export function createUnsupportedFeatureError(message: string = '') {
|
||||
const error = new Error(message);
|
||||
error.name = ErrorsNames.UNSUPPORTTED_FEATURE_ERROR;
|
||||
return error;
|
||||
}
|
||||
+6
-5
@@ -29,7 +29,6 @@ import {
|
||||
ContextProvider,
|
||||
ForwardRef,
|
||||
} from 'react-reconciler/src/ReactWorkTags';
|
||||
import {createUnsupportedFeatureError} from './ReactDebugCustomErrors';
|
||||
|
||||
type CurrentDispatcherRef = typeof ReactSharedInternals.ReactCurrentDispatcher;
|
||||
|
||||
@@ -362,11 +361,13 @@ const Dispatcher: DispatcherType = {
|
||||
const DispatcherProxyHandler = {
|
||||
get(target, prop, _receiver) {
|
||||
if (target.hasOwnProperty(prop)) {
|
||||
return Reflect.get(...arguments);
|
||||
return target[prop];
|
||||
}
|
||||
throw createUnsupportedFeatureError(
|
||||
'Missing method in Dispatcher: ' + prop,
|
||||
);
|
||||
const error = new Error('Missing method in Dispatcher: ' + prop);
|
||||
// Note: This error name needs to stay in sync with react-devtools-shared
|
||||
// TODO: refactor this if we ever combine the devtools and debug tools packages
|
||||
error.name = 'UnsupportedFeatureError';
|
||||
throw error;
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
+1
-2
@@ -8,6 +8,5 @@
|
||||
*/
|
||||
|
||||
import {inspectHooks, inspectHooksOfFiber} from './ReactDebugHooks';
|
||||
import {ErrorsNames} from './ReactDebugCustomErrors';
|
||||
|
||||
export {inspectHooks, inspectHooksOfFiber, ErrorsNames};
|
||||
export {inspectHooks, inspectHooksOfFiber};
|
||||
|
||||
Reference in New Issue
Block a user