diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js
index c494643c474..ed420338c24 100644
--- a/Libraries/Components/View/View.js
+++ b/Libraries/Components/View/View.js
@@ -32,19 +32,24 @@ const RCTView = requireNativeComponent('RCTView');
let ViewToExport = RCTView;
if (__DEV__) {
+ const View = (props: Props, forwardedRef: ?React.Ref<'RCTView'>) => {
+ return (
+
+ {hasTextAncestor => {
+ invariant(
+ !hasTextAncestor,
+ 'Nesting of within is not currently supported.',
+ );
+ return ;
+ }}
+
+ );
+ };
+ View.displayName = 'View'; // TODO(T30332650) remove bug workaround
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
- ViewToExport = React.forwardRef((props, ref) => (
-
- {hasTextAncestor => {
- invariant(
- !hasTextAncestor,
- 'Nesting of within is not currently supported.',
- );
- return ;
- }}
-
- ));
- ViewToExport.displayName = 'View';
+ ViewToExport = React.forwardRef(View);
}
-module.exports = ((ViewToExport: any): Class>);
+module.exports = ((ViewToExport: $FlowFixMe): Class<
+ NativeComponent,
+>);
diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js
index 5da883aa630..aaa283a6daf 100644
--- a/Libraries/Text/Text.js
+++ b/Libraries/Text/Text.js
@@ -261,13 +261,17 @@ const RCTVirtualText =
uiViewClassName: 'RCTVirtualText',
}));
+const Text = (
+ props: TextProps,
+ forwardedRef: ?React.Ref<'RCTText' | 'RCTVirtualText'>,
+) => {
+ return ;
+};
+Text.displayName = 'Text'; // TODO(T30332650) remove bug workaround
// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
-const Text = React.forwardRef((props, ref) => (
-
-));
-Text.displayName = 'Text';
+const TextToExport = React.forwardRef(Text);
// TODO: Deprecate this.
-Text.propTypes = TextPropTypes;
+TextToExport.propTypes = TextPropTypes;
-module.exports = ((Text: any): Class>);
+module.exports = (TextToExport: Class>);
diff --git a/jest/mockComponent.js b/jest/mockComponent.js
index 6d5a80b47e0..3f98a160d5c 100644
--- a/jest/mockComponent.js
+++ b/jest/mockComponent.js
@@ -18,7 +18,12 @@ module.exports = (moduleName, instanceMethods) => {
const Component = class extends SuperClass {
render() {
- const name = RealComponent.displayName || RealComponent.name;
+ const name =
+ RealComponent.displayName ||
+ RealComponent.name ||
+ (RealComponent.render // handle React.forwardRef
+ ? RealComponent.render.displayName || RealComponent.render.name
+ : 'Unknown');
const props = Object.assign({}, RealComponent.defaultProps);