RN: Reduce ForwardRef(View) Noise in Systrace

Summary: When running a trace, reduce the noise from the `__DEV__`-only `ForwardRef(View)` elements.

Reviewed By: ejanzer

Differential Revision: D9445865

fbshipit-source-id: 7cfe87bab6dd62d3800d2ca239724b5063c55c89
This commit is contained in:
Tim Yung
2018-11-07 10:31:13 +00:00
committed by Lorenzo Sciandra
parent ce25c54284
commit 7187f85551
+20 -18
View File
@@ -30,24 +30,26 @@ export type Props = ViewProps;
let ViewToExport = ViewNativeComponent;
if (__DEV__) {
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);
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);
}
}
module.exports = ((ViewToExport: $FlowFixMe): typeof ViewNativeComponent);