Skip to content

Commit 28f1aac

Browse files
elicwhitefacebook-github-bot
authored andcommitted
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 #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
1 parent 122acca commit 28f1aac

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

Libraries/Components/View/View.js

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
'use strict';
1212

13-
const React = require('react');
1413
const ViewNativeComponent = require('./ViewNativeComponent');
1514

1615
import type {ViewProps} from './ViewPropTypes';
@@ -24,19 +23,4 @@ export type Props = ViewProps;
2423
*
2524
* @see http://facebook.github.io/react-native/docs/view.html
2625
*/
27-
28-
let ViewToExport = ViewNativeComponent;
29-
if (__DEV__) {
30-
if (!global.__RCTProfileIsProfiling) {
31-
const View = (
32-
props: Props,
33-
forwardedRef: React.Ref<typeof ViewNativeComponent>,
34-
) => {
35-
return <ViewNativeComponent {...props} ref={forwardedRef} />;
36-
};
37-
ViewToExport = React.forwardRef(View);
38-
ViewToExport.displayName = 'View';
39-
}
40-
}
41-
42-
module.exports = ((ViewToExport: $FlowFixMe): typeof ViewNativeComponent);
26+
module.exports = ((ViewNativeComponent: $FlowFixMe): typeof ViewNativeComponent);

jest/setup.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,21 @@ jest
331331
.mock('../Libraries/ReactNative/requireNativeComponent', () => {
332332
const React = require('react');
333333

334-
return viewName =>
335-
class extends React.Component {
334+
return viewName => {
335+
const Component = class extends React.Component {
336336
render() {
337337
return React.createElement(viewName, this.props, this.props.children);
338338
}
339339
};
340+
341+
if (viewName === 'RCTView') {
342+
Component.displayName = 'View';
343+
} else {
344+
Component.displayName = viewName;
345+
}
346+
347+
return Component;
348+
};
340349
})
341350
.mock(
342351
'../Libraries/Utilities/verifyComponentAttributeEquivalence',

0 commit comments

Comments
 (0)