Skip to content

Commit 8a586f2

Browse files
hoxyqfacebook-github-bot
authored andcommitted
Move setUpReactDevTools to InitializeCore (facebook#48871)
Summary: Pull Request resolved: facebook#48871 # Changelog: [Internal] Forward-fixing D68380665. Requirements: - `setUpReactDevTools` should be called before `setUpErrorHandling` to avoid React DevTools mutating `console.error` call arguments. - `setUpReactDevTools` should be called after `setUpTimers`, because it is using `queueMicrotask`, see https://fb.workplace.com/groups/rn.panelapps/permalink/1120810879540337/. - `setUpTimers` should be called after `polyfillPromise`, because it uses on `global.Promise`. I went over bundles, which are not using `InitializeCore` and using either `setUpErrorHandling` or `setUpDeveloperTools` and updated their order of initialization accordingly. Reviewed By: javache Differential Revision: D68510100 fbshipit-source-id: 4331dcc7a7cb1dc438ca2ed5ccae49e736c41b2a
1 parent c5af752 commit 8a586f2

3 files changed

Lines changed: 21 additions & 7 deletions

File tree

packages/react-native/Libraries/Core/InitializeCore.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,13 @@ const start = Date.now();
3131
require('./setUpGlobals');
3232
require('../../src/private/setup/setUpDOM').default();
3333
require('./setUpPerformance');
34-
require('./setUpErrorHandling');
3534
require('./polyfillPromise');
36-
require('./setUpRegeneratorRuntime');
3735
require('./setUpTimers');
36+
if (__DEV__) {
37+
require('./setUpReactDevTools');
38+
}
39+
require('./setUpErrorHandling');
40+
require('./setUpRegeneratorRuntime');
3841
require('./setUpXHR');
3942
require('./setUpAlert');
4043
require('./setUpNavigator');

packages/react-native/Libraries/Core/setUpErrorHandling.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010

1111
'use strict';
1212

13-
if (__DEV__) {
14-
// React DevTools need to be set up before the console.error patch.
15-
require('./setUpReactDevTools');
16-
}
17-
1813
if (global.RN$useAlwaysAvailableJSErrorHandling !== true) {
1914
/**
2015
* Sets up the console and exception handling (redbox) for React Native.

packages/react-native/Libraries/Core/setUpReactDevTools.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
import type {Domain} from '../../src/private/debugging/setUpFuseboxReactDevToolsDispatcher';
1414
import type {Spec as NativeReactDevToolsRuntimeSettingsModuleSpec} from '../../src/private/fusebox/specs/NativeReactDevToolsRuntimeSettingsModule';
1515

16+
if (__DEV__) {
17+
if (typeof global.queueMicrotask !== 'function') {
18+
console.error(
19+
'queueMicrotask should exist before setting up React DevTools.',
20+
);
21+
}
22+
23+
// Keep in sync with ExceptionsManager/installConsoleErrorReporter
24+
// $FlowExpectedError[prop-missing]
25+
if (console._errorOriginal != null) {
26+
console.error(
27+
'ExceptionsManager should be set up after React DevTools to avoid console.error arguments mutation',
28+
);
29+
}
30+
}
31+
1632
if (__DEV__) {
1733
// Register dispatcher on global, which can be used later by Chrome DevTools frontend
1834
require('../../src/private/debugging/setUpFuseboxReactDevToolsDispatcher');

0 commit comments

Comments
 (0)