Skip to content

Commit

Permalink
[standards] ReactPrivate, an explicit interface between the renderer …
Browse files Browse the repository at this point in the history
…and RN

This introduces a new library named "ReactPrivate" that defines an explicit interface between the React renderers generated by the React repo and the code within RN. Previously, the React renderers would reach into RN internals via Haste wormholes. With this commit, there is now an explicit module (`ReactNativePrivateInterface`) that the renderers use to access RN internals.

Motivation: The main goal is to move one step closer to turning off Haste for RN (facebook#24316). Since the generated renderers currently use Haste, this commit sets the foundation for giving them a path-based interface to access RN internals.

Additionally, this approach inverts abstraction control since RN needs to intentionally export its internals via the private interface instead of React reaching in via Haste.

There will also need to be a corresponding commit to the React repo to make the renderers use this new interface. This RN commit needs to land before the React commit.

Test Plan: Run unit tests, CI. This commit should be safe since it just introduces new modules.

Also tested with newly generated renderers (not in this commit; needs to happen in the React repo) that use ReactPrivate instead of Haste and verified that RNTester loads and that unit tests pass.
  • Loading branch information
ide committed May 14, 2019
1 parent de0d7cf commit b6e0406
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/

import '../Core/InitializeCore';
43 changes: 43 additions & 0 deletions Libraries/ReactPrivate/ReactNativePrivateInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict-local
*/

// flowlint unsafe-getters-setters:off
module.exports = {
get BatchedBridge() {
return require('../BatchedBridge/BatchedBridge.js');
},
get ExceptionsManager() {
return require('../Core/ExceptionsManager');
},
get Platform() {
return require('../Utilities/Platform');
},
get RCTEventEmitter() {
return require('../EventEmitter/RCTEventEmitter');
},
get ReactNativeViewConfigRegistry() {
return require('../Renderer/shims/ReactNativeViewConfigRegistry');
},
get TextInputState() {
return require('../Components/TextInput/TextInputState');
},
get UIManager() {
return require('../ReactNative/UIManager');
},
get deepDiffer() {
return require('../Utilities/differ/deepDiffer');
},
get deepFreezeAndThrowOnMutationInDev() {
return require('../Utilities/deepFreezeAndThrowOnMutationInDev');
},
get flattenStyle() {
return require('../StyleSheet/flattenStyle');
},
};

0 comments on commit b6e0406

Please sign in to comment.