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 9, 2019
1 parent 335c81e commit 4b03978
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js
@@ -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';
33 changes: 33 additions & 0 deletions Libraries/ReactPrivate/ReactNativePrivateInterface.js
@@ -0,0 +1,33 @@
/**
* 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 TextInputState from '../Components/TextInput/TextInputState';
import ExceptionsManager from '../Core/ExceptionsManager';
import RCTEventEmitter from '../EventEmitter/RCTEventEmitter';
import FabricUIManager from '../ReactNative/FabricUIManager';
import UIManager from '../ReactNative/UIManager';
import ReactNativeViewConfigRegistry from '../Renderer/shims/ReactNativeViewConfigRegistry';
import flattenStyle from '../StyleSheet/flattenStyle';
import Platform from '../Utilities/Platform';
import deepFreezeAndThrowOnMutationInDev from '../Utilities/deepFreezeAndThrowOnMutationInDev';
import deepDiffer from '../Utilities/differ/deepDiffer';

export {
ExceptionsManager,
FabricUIManager,
Platform,
RCTEventEmitter,
ReactNativeViewConfigRegistry,
TextInputState,
UIManager,
deepDiffer,
deepFreezeAndThrowOnMutationInDev,
flattenStyle,
};

0 comments on commit 4b03978

Please sign in to comment.