File tree Expand file tree Collapse file tree 2 files changed +33
-208
lines changed Expand file tree Collapse file tree 2 files changed +33
-208
lines changed Original file line number Diff line number Diff line change @@ -36,17 +36,37 @@ const getNodeByText = (node, text) => {
36
36
} ;
37
37
38
38
const getChildrenAsText = children => {
39
- return React . Children . map ( children , child => {
39
+ let textContent = [ ] ;
40
+
41
+ React . Children . map ( children , child => {
40
42
if ( typeof child === 'string' ) {
41
- return child ;
43
+ return textContent . push ( child ) ;
42
44
}
43
45
44
46
if ( typeof child === 'number' ) {
45
- return child . toString ( ) ;
47
+ return textContent . push ( child . toString ( ) ) ;
46
48
}
47
49
48
- return '' ;
50
+ if ( child . props . children ) {
51
+ const { children } = child . props ;
52
+
53
+ if ( children instanceof Array ) {
54
+ children . forEach ( node => {
55
+ // eslint-disable-next-line
56
+ const { Text } = require ( 'react-native' ) ;
57
+ if ( filterNodeByType ( node , Text ) ) {
58
+ return textContent . push ( node . props . children ) ;
59
+ }
60
+ } ) ;
61
+ } else {
62
+ if ( typeof children === 'string' ) {
63
+ return textContent . push ( children ) ;
64
+ }
65
+ }
66
+ }
49
67
} ) ;
68
+
69
+ return textContent ;
50
70
} ;
51
71
52
72
const getTextInputNodeByPlaceholder = ( node , placeholder ) => {
You can’t perform that action at this time.
0 commit comments