Get server host in setupDevtools for Android
Summary:
The `setupDevtools` for Android looks coming on [v0.30](22fbb6d46d
), currently we need to run `adb reverse tcp:8097 tcp:8097`, I think get host IP (`10.0.2.2`, Genymotion: `10.0.3.2`) for Android will be better. (it can be found in `AndroidConstants` native module)
Closes https://github.com/facebook/react-native/pull/8811
Differential Revision: D3586177
Pulled By: javache
fbshipit-source-id: 3bfe04391b0fea608e4d3deab03dd376fab8727c
This commit is contained in:
Родитель
875d5d2364
Коммит
46417dd26a
|
@ -11,10 +11,17 @@
|
||||||
*/
|
*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var Platform = require('Platform');
|
||||||
|
var NativeModules = require('NativeModules');
|
||||||
|
|
||||||
function setupDevtools() {
|
function setupDevtools() {
|
||||||
var messageListeners = [];
|
var messageListeners = [];
|
||||||
var closeListeners = [];
|
var closeListeners = [];
|
||||||
var ws = new window.WebSocket('ws://localhost:8097/devtools');
|
var hostname = 'localhost';
|
||||||
|
if (Platform.OS === 'android' && NativeModules.AndroidConstants) {
|
||||||
|
hostname = NativeModules.AndroidConstants.ServerHost.split(':')[0];
|
||||||
|
}
|
||||||
|
var ws = new window.WebSocket('ws://' + hostname + ':8097/devtools');
|
||||||
// this is accessed by the eval'd backend code
|
// this is accessed by the eval'd backend code
|
||||||
var FOR_BACKEND = { // eslint-disable-line no-unused-vars
|
var FOR_BACKEND = { // eslint-disable-line no-unused-vars
|
||||||
resolveRNStyle: require('flattenStyle'),
|
resolveRNStyle: require('flattenStyle'),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче