From 28f1aac88cabedc6c31a99dea52f196ec1e0393a Mon Sep 17 00:00:00 2001 From: Eli White Date: Thu, 20 Jun 2019 18:24:31 -0700 Subject: [PATCH] Remove extra component wrapper from View Summary: View needed this wrapper to add a dev time warning about text children. Text children became supported and this warning was removed in https://github.com/facebook/react-native/pull/23195 This check is no longer necessary and we can reduce the overhead and improve the performance of View by removing this. Reviewed By: rickhanlonii Differential Revision: D15914658 fbshipit-source-id: 6456a9cb356245fa8104036b2948aa5c5bf39e0f --- Libraries/Components/View/View.js | 18 +----------------- jest/setup.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index c321d7f87a7cbc..7d61e30a111137 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -10,7 +10,6 @@ 'use strict'; -const React = require('react'); const ViewNativeComponent = require('./ViewNativeComponent'); import type {ViewProps} from './ViewPropTypes'; @@ -24,19 +23,4 @@ export type Props = ViewProps; * * @see http://facebook.github.io/react-native/docs/view.html */ - -let ViewToExport = ViewNativeComponent; -if (__DEV__) { - if (!global.__RCTProfileIsProfiling) { - const View = ( - props: Props, - forwardedRef: React.Ref, - ) => { - return ; - }; - ViewToExport = React.forwardRef(View); - ViewToExport.displayName = 'View'; - } -} - -module.exports = ((ViewToExport: $FlowFixMe): typeof ViewNativeComponent); +module.exports = ((ViewNativeComponent: $FlowFixMe): typeof ViewNativeComponent); diff --git a/jest/setup.js b/jest/setup.js index 231c2c653146c5..8c710256a64a7d 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -331,12 +331,21 @@ jest .mock('../Libraries/ReactNative/requireNativeComponent', () => { const React = require('react'); - return viewName => - class extends React.Component { + return viewName => { + const Component = class extends React.Component { render() { return React.createElement(viewName, this.props, this.props.children); } }; + + if (viewName === 'RCTView') { + Component.displayName = 'View'; + } else { + Component.displayName = viewName; + } + + return Component; + }; }) .mock( '../Libraries/Utilities/verifyComponentAttributeEquivalence',