mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add all injection necessary for error logging
This commit is contained in:
@@ -157,6 +157,8 @@ function getCommonJsConfig(bundleType) {
|
||||
// At FB, we don't know them statically:
|
||||
'ReactFeatureFlags',
|
||||
'ReactDOMFeatureFlags',
|
||||
// At FB, we fork this module for custom reporting flow:
|
||||
'ReactErrorUtils',
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ ReactDOMFiber.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
||||
// These are real internal dependencies that are trickier to remove:
|
||||
EventPluginHub: require('EventPluginHub'),
|
||||
ReactBrowserEventEmitter: require('ReactBrowserEventEmitter'),
|
||||
ReactFiberErrorLogger: require('ReactFiberErrorLogger'),
|
||||
ReactDOMComponentTree: require('ReactDOMComponentTree'),
|
||||
ReactInstanceMap: require('react-dom/lib/ReactInstanceMap'),
|
||||
// This is used for ajaxify on www:
|
||||
|
||||
@@ -12,8 +12,13 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const emptyFunction = require('emptyFunction');
|
||||
const invariant = require('invariant');
|
||||
|
||||
import type { CapturedError } from 'ReactFiberScheduler';
|
||||
|
||||
let showDialog = emptyFunction;
|
||||
|
||||
function logCapturedError(capturedError : CapturedError) : void {
|
||||
if (__DEV__) {
|
||||
const {
|
||||
@@ -84,7 +89,19 @@ function logCapturedError(capturedError : CapturedError) : void {
|
||||
`React caught an error thrown by one of your components.\n\n${error.stack}`
|
||||
);
|
||||
}
|
||||
|
||||
showDialog(capturedError);
|
||||
}
|
||||
|
||||
exports.injection = {
|
||||
injectDialog(fn) {
|
||||
invariant(
|
||||
typeof fn === 'function',
|
||||
'Injected showDialog() must be a function.'
|
||||
);
|
||||
showDialog = fn;
|
||||
},
|
||||
};
|
||||
|
||||
exports.logCapturedError = logCapturedError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user