Skip to content

Commit

Permalink
Remove setupDevtools file
Browse files Browse the repository at this point in the history
Summary: There is a `setUpDeveloperTools.js` and a `setupDevtools.js` files. While they do set up different devtools it is very confusing to have these two files. This diff inlines one in the other which should bring more clarity.

Reviewed By: gaearon

Differential Revision: D16121236

fbshipit-source-id: 45641c7af9639ede6dc237ac53b763cd804a05c2
  • Loading branch information
cpojer authored and facebook-github-bot committed Jul 4, 2019
1 parent 76e10c4 commit 5dade01
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 49 deletions.
46 changes: 0 additions & 46 deletions Libraries/Core/Devtools/setupDevtools.js

This file was deleted.

26 changes: 25 additions & 1 deletion Libraries/Core/setUpDeveloperTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,31 @@ if (__DEV__) {
// not when debugging in chrome
// TODO(t12832058) This check is broken
if (!window.document) {
require('./Devtools/setupDevtools');
const AppState = require('../AppState/AppState');
// $FlowFixMe Module is untyped
const reactDevTools = require('react-devtools-core');
const getDevServer = require('./Devtools/getDevServer');

// Don't steal the DevTools from currently active app.
// Note: if you add any AppState subscriptions to this file,
// you will also need to guard against `AppState.isAvailable`,
// or the code will throw for bundles that don't have it.
const isAppActive = () => AppState.currentState !== 'background';

// Get hostname from development server (packager)
const devServer = getDevServer();
const host = devServer.bundleLoadedFromServer
? devServer.url.replace(/https?:\/\//, '').split(':')[0]
: 'localhost';

reactDevTools.connectToDevTools({
isAppActive,
host,
// Read the optional global variable for backward compatibility.
// It was added in https://github.com/facebook/react-native/commit/bf2b435322e89d0aeee8792b1c6e04656c2719a0.
port: window.__REACT_DEVTOOLS_PORT__,
resolveRNStyle: require('../StyleSheet/flattenStyle'),
});
}

// Set up inspector
Expand Down
2 changes: 0 additions & 2 deletions jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ global.cancelAnimationFrame = function(id) {
clearTimeout(id);
};

jest.mock('../Libraries/Core/Devtools/setupDevtools');

// there's a __mock__ for it.
jest.setMock(
'../Libraries/vendor/core/ErrorUtils',
Expand Down

0 comments on commit 5dade01

Please sign in to comment.