Skip to content

Commit 7a914fc

Browse files
rajivshah3facebook-github-bot
authored andcommitted
Fix View/Text displayName (#21950)
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 #21937 Pull Request resolved: #21950 Differential Revision: D12827060 Pulled By: TheSavior fbshipit-source-id: d812cae14d53ad821ab5873e737db63ad1a989e3
1 parent c91a2b3 commit 7a914fc

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

Libraries/Components/View/View.js

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ if (__DEV__) {
4949
};
5050
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
5151
ViewToExport = React.forwardRef(View);
52+
ViewToExport.displayName = 'View';
5253
}
5354
}
5455

Libraries/Text/Text.js

+1
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ const Text = (
277277
};
278278
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
279279
const TextToExport = React.forwardRef(Text);
280+
TextToExport.displayName = 'Text';
280281

281282
// TODO: Deprecate this.
282283
TextToExport.propTypes = DeprecatedTextPropTypes;

Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap

+22-22
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,94 @@
22

33
exports[`YellowBoxCategory renders a single substitution 1`] = `
44
Array [
5-
<Component
5+
<Text
66
style={
77
Object {
88
"fontWeight": "bold",
99
}
1010
}
1111
>
1212
"A"
13-
</Component>,
13+
</Text>,
1414
]
1515
`;
1616

1717
exports[`YellowBoxCategory renders content with no substitutions 1`] = `
1818
Array [
19-
<Component>
19+
<Text>
2020
A
21-
</Component>,
21+
</Text>,
2222
]
2323
`;
2424

2525
exports[`YellowBoxCategory renders multiple substitutions 1`] = `
2626
Array [
27-
<Component
27+
<Text
2828
style={
2929
Object {
3030
"fontWeight": "bold",
3131
}
3232
}
3333
>
3434
"A"
35-
</Component>,
36-
<Component>
35+
</Text>,
36+
<Text>
3737
38-
</Component>,
39-
<Component
38+
</Text>,
39+
<Text
4040
style={
4141
Object {
4242
"fontWeight": "bold",
4343
}
4444
}
4545
>
4646
"B"
47-
</Component>,
48-
<Component>
47+
</Text>,
48+
<Text>
4949
50-
</Component>,
51-
<Component
50+
</Text>,
51+
<Text
5252
style={
5353
Object {
5454
"fontWeight": "bold",
5555
}
5656
}
5757
>
5858
"C"
59-
</Component>,
59+
</Text>,
6060
]
6161
`;
6262

6363
exports[`YellowBoxCategory renders substitutions with leading content 1`] = `
6464
Array [
65-
<Component>
65+
<Text>
6666
!
67-
</Component>,
68-
<Component
67+
</Text>,
68+
<Text
6969
style={
7070
Object {
7171
"fontWeight": "bold",
7272
}
7373
}
7474
>
7575
"A"
76-
</Component>,
76+
</Text>,
7777
]
7878
`;
7979

8080
exports[`YellowBoxCategory renders substitutions with trailing content 1`] = `
8181
Array [
82-
<Component
82+
<Text
8383
style={
8484
Object {
8585
"fontWeight": "bold",
8686
}
8787
}
8888
>
8989
"A"
90-
</Component>,
91-
<Component>
90+
</Text>,
91+
<Text>
9292
!
93-
</Component>,
93+
</Text>,
9494
]
9595
`;

0 commit comments

Comments
 (0)