diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 2cfa05a8c11..35c0bfa4e8c 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -12,11 +12,10 @@ const React = require('React'); const TextAncestor = require('TextAncestor'); +const ViewNativeComponent = require('ViewNativeComponent'); const invariant = require('fbjs/lib/invariant'); -const requireNativeComponent = require('requireNativeComponent'); -import type {NativeComponent} from 'ReactNative'; import type {ViewProps} from 'ViewPropTypes'; export type Props = ViewProps; @@ -28,11 +27,13 @@ export type Props = ViewProps; * * @see http://facebook.github.io/react-native/docs/view.html */ -const RCTView = requireNativeComponent('RCTView'); -let ViewToExport = RCTView; +let ViewToExport = ViewNativeComponent; if (__DEV__) { - const View = (props: Props, forwardedRef: ?React.Ref<'RCTView'>) => { + const View = ( + props: Props, + forwardedRef: React.Ref, + ) => { return ( {hasTextAncestor => { @@ -40,7 +41,7 @@ if (__DEV__) { !hasTextAncestor, 'Nesting of within is not currently supported.', ); - return ; + return ; }} ); @@ -49,6 +50,4 @@ if (__DEV__) { ViewToExport = React.forwardRef(View); } -module.exports = ((ViewToExport: $FlowFixMe): Class< - NativeComponent, ->); +module.exports = ((ViewToExport: $FlowFixMe): typeof ViewNativeComponent); diff --git a/Libraries/Components/View/ViewNativeComponent.js b/Libraries/Components/View/ViewNativeComponent.js new file mode 100644 index 00000000000..728e81beb41 --- /dev/null +++ b/Libraries/Components/View/ViewNativeComponent.js @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + * @flow + */ + +'use strict'; + +const ReactNative = require('ReactNative'); + +const requireNativeComponent = require('requireNativeComponent'); + +import type {ViewProps} from 'ViewPropTypes'; + +type ViewNativeComponentType = Class>; + +const ViewNativeComponent = ((requireNativeComponent( + 'RCTView', +): any): ViewNativeComponentType); + +module.exports = ViewNativeComponent;