diff --git a/Libraries/ReactNative/AppContainer.js b/Libraries/ReactNative/AppContainer.js index 22e3bd3bef..93c83fba66 100644 --- a/Libraries/ReactNative/AppContainer.js +++ b/Libraries/ReactNative/AppContainer.js @@ -14,7 +14,7 @@ const EmitterSubscription = require('../vendor/emitter/EmitterSubscription'); const PropTypes = require('prop-types'); const RCTDeviceEventEmitter = require('../EventEmitter/RCTDeviceEventEmitter'); const React = require('react'); -const RootTagContext = require('./RootTagContext'); +import {RootTagContext, createRootTag} from './RootTag'; const StyleSheet = require('../StyleSheet/StyleSheet'); const View = require('../Components/View/View'); @@ -128,7 +128,7 @@ class AppContainer extends React.Component { ); } return ( - + {!this.state.hasError && innerView} {this.state.inspector} diff --git a/Libraries/ReactNative/RootTag.js b/Libraries/ReactNative/RootTag.js new file mode 100644 index 0000000000..24b151544d --- /dev/null +++ b/Libraries/ReactNative/RootTag.js @@ -0,0 +1,27 @@ +/** + * 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. + * + * @flow strict + * @format + */ + +'use strict'; + +import * as React from 'react'; + +// TODO: Make this into an opaque type. +export type RootTag = number; + +export const RootTagContext: React$Context = React.createContext( + 0, +); + +/** + * Intended to only be used by `AppContainer`. + */ +export function createRootTag(rootTag: number): RootTag { + return rootTag; +} diff --git a/Libraries/ReactNative/RootTagContext.js b/Libraries/ReactNative/RootTagContext.js deleted file mode 100644 index ca5ed03932..0000000000 --- a/Libraries/ReactNative/RootTagContext.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * 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. - * - * @flow strict - * @format - */ - -'use strict'; - -const React = require('react'); - -module.exports = (React.createContext(0): React$Context); diff --git a/index.js b/index.js index 1290bb728b..9d5a6dcb14 100644 --- a/index.js +++ b/index.js @@ -95,7 +95,7 @@ import typeof Platform from './Libraries/Utilities/Platform'; import typeof processColor from './Libraries/StyleSheet/processColor'; import typeof {PlatformColor} from './Libraries/StyleSheet/PlatformColorValueTypes'; import typeof {DynamicColorIOS} from './Libraries/StyleSheet/PlatformColorValueTypesIOS'; -import typeof RootTagContext from './Libraries/ReactNative/RootTagContext'; +import typeof {RootTagContext} from './Libraries/ReactNative/RootTag'; import typeof DeprecatedColorPropType from './Libraries/DeprecatedPropTypes/DeprecatedColorPropType'; import typeof DeprecatedEdgeInsetsPropType from './Libraries/DeprecatedPropTypes/DeprecatedEdgeInsetsPropType'; import typeof DeprecatedPointPropType from './Libraries/DeprecatedPropTypes/DeprecatedPointPropType'; @@ -468,7 +468,7 @@ module.exports = { return require('./Libraries/ReactNative/requireNativeComponent'); }, get unstable_RootTagContext(): RootTagContext { - return require('./Libraries/ReactNative/RootTagContext'); + return require('./Libraries/ReactNative/RootTag').RootTagContext; }, get unstable_enableLogBox(): () => void { return () =>