mirror of
https://github.com/status-im/react-native.git
synced 2025-02-28 09:00:55 +00:00
Summary: The way React DevTools integration was set up in RN was not entirely supported by the React team, and we had to disable it in c3b25c9059f57ee8df5505628ff6221f11cf9234 so that we can move forward with enabling Fiber support in React Native. Here, I am moving the DevTools client setup from RN repo to [React DevTools repo](https://github.com/facebook/react-devtools/blob/master/packages/react-devtools-core/README.md#requirereact-devtools-coreconnecttodevtoolsoptions) so that we can keep it in sync with the rest of React DevTools. This is also a part of a larger effort to consolidate DevTools code (https://github.com/facebook/react-devtools/issues/489). It allows us to remove the double injection of the hook, an lets us replace the `eval` hack with a regular dependency. The implementation [lives here now](https://github.com/facebook/react-devtools/blob/master/packages/react-devtools-core/src/backend.js). This change re-enables Nuclide Inspector with React Native Stack reconciler and prepares it for compatibi Closes https://github.com/facebook/react-native/pull/12316 Reviewed By: zertosh Differential Revision: D4545322 Pulled By: gaearon fbshipit-source-id: ab949916c1a92c6b41cd41e7e1edf9697a71de2e
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* @providesModule setupDevtools
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
if (__DEV__) {
|
|
var AppState = require('AppState');
|
|
var NativeModules = require('NativeModules');
|
|
var Platform = require('Platform');
|
|
var {connectToDevTools} = require('react-devtools-core');
|
|
|
|
connectToDevTools({
|
|
isAppActive() {
|
|
// Don't steal the DevTools from currently active app.
|
|
return AppState.currentState !== 'background';
|
|
},
|
|
// Special case: Genymotion is running on a different host.
|
|
host: (Platform.OS === 'android' && NativeModules.AndroidConstants) ?
|
|
NativeModules.AndroidConstants.ServerHost.split(':')[0] :
|
|
'localhost',
|
|
// 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('flattenStyle'),
|
|
});
|
|
}
|