mirror of
https://github.com/status-im/react-native.git
synced 2025-02-06 06:34:01 +00:00
8dc3ba0444
Summary: As we migrate over to static typing solutions for props, we cannot rely on always having `propTypes` available at runtime. This gets us started on that journey by removing the native prop validation that happens when we require native components. bypass-lint Reviewed By: TheSavior Differential Revision: D7976854 fbshipit-source-id: f3ab579a7f0f8cfb716b0eb7fd4625f8168f3d96
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
/**
|
|
* 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 React = require('React');
|
|
const TextAncestor = require('TextAncestor');
|
|
|
|
const invariant = require('fbjs/lib/invariant');
|
|
const requireNativeComponent = require('requireNativeComponent');
|
|
|
|
import type {NativeComponent} from 'ReactNative';
|
|
import type {ViewProps} from 'ViewPropTypes';
|
|
|
|
export type Props = ViewProps;
|
|
|
|
/**
|
|
* The most fundamental component for building a UI, View is a container that
|
|
* supports layout with flexbox, style, some touch handling, and accessibility
|
|
* controls.
|
|
*
|
|
* @see http://facebook.github.io/react-native/docs/view.html
|
|
*/
|
|
const RCTView = requireNativeComponent('RCTView');
|
|
|
|
let ViewToExport = RCTView;
|
|
if (__DEV__) {
|
|
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
|
|
ViewToExport = React.forwardRef((props, ref) => (
|
|
<TextAncestor.Consumer>
|
|
{hasTextAncestor => {
|
|
invariant(
|
|
!hasTextAncestor,
|
|
'Nesting of <View> within <Text> is not currently supported.',
|
|
);
|
|
return <RCTView {...props} ref={ref} />;
|
|
}}
|
|
</TextAncestor.Consumer>
|
|
));
|
|
ViewToExport.displayName = 'View';
|
|
}
|
|
|
|
module.exports = ((ViewToExport: any): Class<NativeComponent<ViewProps>>);
|