Skip to content

Commit

Permalink
Fix View/Text displayName (facebook#21950)
Browse files Browse the repository at this point in the history
Summary:
Adds the displayName prop to `View` and `Text` components. Because these now use `React.forwardRef`, they were showing as `Component` instead of their actual names.

Thanks to ljharb for helping to pinpoint the source of the issue!

Fixes facebook#21937
Pull Request resolved: facebook#21950

Differential Revision: D12827060

Pulled By: TheSavior

fbshipit-source-id: d812cae14d53ad821ab5873e737db63ad1a989e3
  • Loading branch information
rajivshah3 authored and facebook-github-bot committed Oct 29, 2018
1 parent c91a2b3 commit 7a914fc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
1 change: 1 addition & 0 deletions Libraries/Components/View/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if (__DEV__) {
};
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
ViewToExport = React.forwardRef(View);
ViewToExport.displayName = 'View';
}
}

Expand Down
1 change: 1 addition & 0 deletions Libraries/Text/Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ const Text = (
};
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
const TextToExport = React.forwardRef(Text);
TextToExport.displayName = 'Text';

// TODO: Deprecate this.
TextToExport.propTypes = DeprecatedTextPropTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,94 +2,94 @@

exports[`YellowBoxCategory renders a single substitution 1`] = `
Array [
<Component
<Text
style={
Object {
"fontWeight": "bold",
}
}
>
"A"
</Component>,
</Text>,
]
`;

exports[`YellowBoxCategory renders content with no substitutions 1`] = `
Array [
<Component>
<Text>
A
</Component>,
</Text>,
]
`;

exports[`YellowBoxCategory renders multiple substitutions 1`] = `
Array [
<Component
<Text
style={
Object {
"fontWeight": "bold",
}
}
>
"A"
</Component>,
<Component>
</Text>,
<Text>
</Component>,
<Component
</Text>,
<Text
style={
Object {
"fontWeight": "bold",
}
}
>
"B"
</Component>,
<Component>
</Text>,
<Text>
</Component>,
<Component
</Text>,
<Text
style={
Object {
"fontWeight": "bold",
}
}
>
"C"
</Component>,
</Text>,
]
`;

exports[`YellowBoxCategory renders substitutions with leading content 1`] = `
Array [
<Component>
<Text>
!
</Component>,
<Component
</Text>,
<Text
style={
Object {
"fontWeight": "bold",
}
}
>
"A"
</Component>,
</Text>,
]
`;

exports[`YellowBoxCategory renders substitutions with trailing content 1`] = `
Array [
<Component
<Text
style={
Object {
"fontWeight": "bold",
}
}
>
"A"
</Component>,
<Component>
</Text>,
<Text>
!
</Component>,
</Text>,
]
`;

0 comments on commit 7a914fc

Please sign in to comment.