Skip to content

Commit

Permalink
ReactPrivate, an explicit interface between the renderer and RN (#24782)
Browse files Browse the repository at this point in the history
Summary:
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 (#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.

## Changelog

[General] [Changed] - Add a private interface (do not use) between the renderer and RN
Pull Request resolved: #24782

Differential Revision: D15413477

Pulled By: cpojer

fbshipit-source-id: 3766ad4cf129fad0c82f0ddc7a485a4ba313b2c4
  • Loading branch information
ide authored and facebook-github-bot committed May 20, 2019
1 parent 3ccfbd6 commit 9cd8825
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 127 deletions.
1 change: 0 additions & 1 deletion Libraries/Animated/release/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/lib/
/dist/
/node_modules/
2 changes: 1 addition & 1 deletion lib/README → Libraries/ReactPrivate/README
Original file line number Diff line number Diff line change
@@ -1 +1 @@
JS modules in this folder are forwarding modules to allow React to require React Native internals as node dependencies.
JS modules in this folder are forwarding modules to allow React to require React Native internals.
6 changes: 1 addition & 5 deletions lib/View.js → ...ivate/ReactNativePrivateInitializeCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@
* @flow strict-local
*/

'use strict';

// This is a forwarding module to allow React to require React Native internals
// as node dependency
module.exports = require('View');
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');
},
};
15 changes: 0 additions & 15 deletions lib/InitializeJavaScriptAppEngine.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/RCTEventEmitter.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/TextInputState.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/UIManager.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/UIManagerStatTracker.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/deepDiffer.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/deepFreezeAndThrowOnMutationInDev.js

This file was deleted.

15 changes: 0 additions & 15 deletions lib/flattenStyle.js

This file was deleted.

0 comments on commit 9cd8825

Please sign in to comment.