File tree Expand file tree Collapse file tree 3 files changed +34
-20
lines changed
Expand file tree Collapse file tree 3 files changed +34
-20
lines changed Original file line number Diff line number Diff line change @@ -32,19 +32,24 @@ const RCTView = requireNativeComponent('RCTView');
3232
3333let ViewToExport = RCTView ;
3434if ( __DEV__ ) {
35+ const View = ( props : Props , forwardedRef : ?React . Ref < 'RCTView' > ) => {
36+ return (
37+ < TextAncestor . Consumer >
38+ { hasTextAncestor => {
39+ invariant (
40+ ! hasTextAncestor ,
41+ 'Nesting of <View> within <Text> is not currently supported.' ,
42+ ) ;
43+ return < RCTView { ...props } ref = { forwardedRef } /> ;
44+ } }
45+ </ TextAncestor . Consumer >
46+ ) ;
47+ } ;
48+ View . displayName = 'View' ; // TODO(T30332650) remove bug workaround
3549 // $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
36- ViewToExport = React . forwardRef ( ( props , ref ) => (
37- < TextAncestor . Consumer >
38- { hasTextAncestor => {
39- invariant (
40- ! hasTextAncestor ,
41- 'Nesting of <View> within <Text> is not currently supported.' ,
42- ) ;
43- return < RCTView { ...props } ref = { ref } /> ;
44- } }
45- </ TextAncestor . Consumer >
46- ) ) ;
47- ViewToExport . displayName = 'View' ;
50+ ViewToExport = React . forwardRef ( View ) ;
4851}
4952
50- module . exports = ( ( ViewToExport : any ) : Class < NativeComponent < ViewProps >> ) ;
53+ module . exports = ( ( ViewToExport : $FlowFixMe ) : Class <
54+ NativeComponent < ViewProps > ,
55+ > ) ;
Original file line number Diff line number Diff line change @@ -261,13 +261,17 @@ const RCTVirtualText =
261261 uiViewClassName : 'RCTVirtualText' ,
262262 } ) ) ;
263263
264+ const Text = (
265+ props : TextProps ,
266+ forwardedRef : ?React . Ref < 'RCTText' | 'RCTVirtualText' > ,
267+ ) = > {
268+ return < TouchableText { ...props } forwardedRef = { forwardedRef } /> ;
269+ } ;
270+ Text . displayName = 'Text' ; // TODO(T30332650) remove bug workaround
264271// $FlowFixMe - TODO T29156721 `React.forwardRef` is not defined in Flow, yet.
265- const Text = React . forwardRef ( ( props , ref ) => (
266- < TouchableText { ...props } forwardedRef = { ref } />
267- ) ) ;
268- Text . displayName = 'Text' ;
272+ const TextToExport = React . forwardRef ( Text ) ;
269273
270274// TODO: Deprecate this.
271- Text . propTypes = TextPropTypes ;
275+ TextToExport . propTypes = TextPropTypes ;
272276
273- module . exports = ( ( Text : any ) : Class < NativeComponent < TextProps >> ) ;
277+ module . exports = ( TextToExport : Class < NativeComponent < TextProps >> ) ;
Original file line number Diff line number Diff line change @@ -18,7 +18,12 @@ module.exports = (moduleName, instanceMethods) => {
1818
1919 const Component = class extends SuperClass {
2020 render ( ) {
21- const name = RealComponent . displayName || RealComponent . name ;
21+ const name =
22+ RealComponent . displayName ||
23+ RealComponent . name ||
24+ ( RealComponent . render // handle React.forwardRef
25+ ? RealComponent . render . displayName || RealComponent . render . name
26+ : 'Unknown' ) ;
2227
2328 const props = Object . assign ( { } , RealComponent . defaultProps ) ;
2429
You can’t perform that action at this time.
0 commit comments