Skip to content

Commit

Permalink
RN: Reduce ForwardRef(View) Noise in Systrace
Browse files Browse the repository at this point in the history
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
  • Loading branch information
yungsters authored and facebook-github-bot committed Aug 23, 2018
1 parent bce77c8 commit 3aea678
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

0 comments on commit 3aea678

Please sign in to comment.