diff --git a/Libraries/Core/Devtools/setupDevtools.js b/Libraries/Core/Devtools/setupDevtools.js index 3658c652b769a9..df3c06c13725b5 100644 --- a/Libraries/Core/Devtools/setupDevtools.js +++ b/Libraries/Core/Devtools/setupDevtools.js @@ -30,6 +30,7 @@ if (__DEV__) { const WebSocket = require('WebSocket'); const {PlatformConstants} = require('NativeModules'); const reactDevTools = require('react-devtools-core'); + const getDevServer = require('getDevServer'); register = function (plugin: DevToolsPlugin) { // Initialize dev tools only if the native module for WebSocket is available @@ -40,10 +41,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'; plugin.connectToDevTools({ isAppActive,