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 36ad95e
Show file tree
Hide file tree
Showing 2 changed files with 31 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
*/

import '../Core/InitializeCore';
20 changes: 20 additions & 0 deletions Libraries/ReactPrivate/ReactNativePrivateInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* 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
*/

export TextInputState from '../Components/TextInput/TextInputState';
export ExceptionsManager from '../Core/ExceptionsManager';
export RCTEventEmitter from '../EventEmitter/RCTEventEmitter';
export FabricUIManager from '../ReactNative/FabricUIManager';
export UIManager from '../ReactNative/UIManager';
export ReactNativeViewConfigRegistry from '../Renderer/shims/ReactNativeViewConfigRegistry';
export flattenStyle from '../StyleSheet/flattenStyle';
export Platform from '../Utilities/Platform';
export deepFreezeAndThrowOnMutationInDev from '../Utilities/deepFreezeAndThrowOnMutationInDev';
export deepDiffer from '../Utilities/differ/deepDiffer';

0 comments on commit 36ad95e

Please sign in to comment.