From 7a914fcef4ae035221e1f984c104ba20430d6fad Mon Sep 17 00:00:00 2001 From: Rajiv Shah Date: Mon, 29 Oct 2018 12:39:58 -0700 Subject: [PATCH] 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: https://github.com/facebook/react-native/pull/21950 Differential Revision: D12827060 Pulled By: TheSavior fbshipit-source-id: d812cae14d53ad821ab5873e737db63ad1a989e3 --- Libraries/Components/View/View.js | 1 + Libraries/Text/Text.js | 1 + .../YellowBoxCategory-test.js.snap | 44 +++++++++---------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 46e55feb8be3f8..0c4cca3271eaa0 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -49,6 +49,7 @@ if (__DEV__) { }; // $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet. ViewToExport = React.forwardRef(View); + ViewToExport.displayName = 'View'; } } diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 02c4ce284843f5..f1b6c807874f95 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -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; diff --git a/Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap b/Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap index ee88875c3717c9..1a527066b06c52 100644 --- a/Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap +++ b/Libraries/YellowBox/Data/__tests__/__snapshots__/YellowBoxCategory-test.js.snap @@ -2,7 +2,7 @@ exports[`YellowBoxCategory renders a single substitution 1`] = ` Array [ - "A" - , + , ] `; exports[`YellowBoxCategory renders content with no substitutions 1`] = ` Array [ - + A - , + , ] `; exports[`YellowBoxCategory renders multiple substitutions 1`] = ` Array [ - "A" - , - + , + - , - , + "B" - , - + , + - , - , + "C" - , + , ] `; exports[`YellowBoxCategory renders substitutions with leading content 1`] = ` Array [ - + ! - , - , + "A" - , + , ] `; exports[`YellowBoxCategory renders substitutions with trailing content 1`] = ` Array [ - "A" - , - + , + ! - , + , ] `;