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-08-22 17:32:12 -07:00 committed by Facebook Github Bot
parent bce77c8b3b
commit 3aea678c38

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);