Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set host of development server for setupDevtools #15547

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Libraries/Core/Devtools/setupDevtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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,
Expand Down