From 54511f35b352578773c6b3af0a619166fb09b94b Mon Sep 17 00:00:00 2001 From: Jhen Date: Thu, 5 Oct 2017 18:10:10 +0800 Subject: [PATCH] Set host of development server for setupDevtools --- Libraries/Core/Devtools/setupDevtools.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Libraries/Core/Devtools/setupDevtools.js b/Libraries/Core/Devtools/setupDevtools.js index 869eb7ccda4002..b1c32960abf5a9 100644 --- a/Libraries/Core/Devtools/setupDevtools.js +++ b/Libraries/Core/Devtools/setupDevtools.js @@ -28,11 +28,11 @@ let register = function () { if (__DEV__) { const AppState = require('AppState'); const WebSocket = require('WebSocket'); - const {PlatformConstants} = require('NativeModules'); /* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an * error found when Flow v0.54 was deployed. To see the error delete this * comment and run Flow. */ const reactDevTools = require('react-devtools-core'); + const getDevServer = require('getDevServer'); // Initialize dev tools only if the native module for WebSocket is available if (WebSocket.isAvailable) { @@ -42,10 +42,11 @@ if (__DEV__) { // or the code will throw for bundles that don't have it. const isAppActive = () => AppState.currentState !== 'background'; - // Special case: Genymotion is running on a different host. - const host = PlatformConstants && PlatformConstants.ServerHost ? - PlatformConstants.ServerHost.split(':')[0] : - 'localhost'; + // Get hostname from development server (packager) + const devServer = getDevServer(); + const host = devServer.bundleLoadedFromServer + ? devServer.url.replace(/https?:\/\//, '').split(':')[0] + : 'localhost'; reactDevTools.connectToDevTools({ isAppActive,