2015-02-19 20:10:52 -08:00
|
|
|
/**
|
2015-03-23 13:35:08 -07:00
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-16 18:24:55 -08:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-02-19 20:10:52 -08:00
|
|
|
*
|
2018-01-14 19:32:26 -08:00
|
|
|
* @format
|
2018-08-09 08:32:04 -07:00
|
|
|
* @flow strict-local
|
2015-02-19 20:10:52 -08:00
|
|
|
*/
|
2018-05-09 00:47:46 -07:00
|
|
|
|
2015-02-19 20:10:52 -08:00
|
|
|
'use strict';
|
|
|
|
|
2017-05-23 07:55:52 -07:00
|
|
|
const React = require('React');
|
2018-05-09 00:47:46 -07:00
|
|
|
const TextAncestor = require('TextAncestor');
|
2018-08-08 18:34:26 -07:00
|
|
|
const ViewNativeComponent = require('ViewNativeComponent');
|
2018-05-09 00:47:46 -07:00
|
|
|
|
2017-01-25 10:31:40 -08:00
|
|
|
const invariant = require('fbjs/lib/invariant');
|
2016-02-15 15:13:42 -08:00
|
|
|
|
2017-05-23 07:55:52 -07:00
|
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
|
|
|
|
|
|
export type Props = ViewProps;
|
|
|
|
|
2015-02-19 20:10:52 -08:00
|
|
|
/**
|
2018-03-09 18:26:58 -08:00
|
|
|
* The most fundamental component for building a UI, View is a container that
|
|
|
|
* supports layout with flexbox, style, some touch handling, and accessibility
|
|
|
|
* controls.
|
2015-02-19 20:10:52 -08:00
|
|
|
*
|
2018-03-09 18:26:58 -08:00
|
|
|
* @see http://facebook.github.io/react-native/docs/view.html
|
2015-02-19 20:10:52 -08:00
|
|
|
*/
|
|
|
|
|
2018-08-08 18:34:26 -07:00
|
|
|
let ViewToExport = ViewNativeComponent;
|
2017-06-21 12:23:58 -07:00
|
|
|
if (__DEV__) {
|
2018-08-22 17:32:12 -07:00
|
|
|
if (!global.__RCTProfileIsProfiling) {
|
|
|
|
const View = (
|
|
|
|
props: Props,
|
|
|
|
forwardedRef: React.Ref<typeof ViewNativeComponent>,
|
|
|
|
) => {
|
|
|
|
return (
|
|
|
|
<TextAncestor.Consumer>
|
|
|
|
{hasTextAncestor => {
|
|
|
|
invariant(
|
|
|
|
!hasTextAncestor,
|
|
|
|
'Nesting of <View> within <Text> is not currently supported.',
|
|
|
|
);
|
|
|
|
return <ViewNativeComponent {...props} ref={forwardedRef} />;
|
|
|
|
}}
|
|
|
|
</TextAncestor.Consumer>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
|
|
|
|
ViewToExport = React.forwardRef(View);
|
|
|
|
}
|
2015-02-19 20:10:52 -08:00
|
|
|
}
|
|
|
|
|
2018-08-08 18:34:26 -07:00
|
|
|
module.exports = ((ViewToExport: $FlowFixMe): typeof ViewNativeComponent);
|