-
Notifications
You must be signed in to change notification settings - Fork 276
feat: query nested text nodes #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,17 +36,37 @@ const getNodeByText = (node, text) => { | |
| }; | ||
|
|
||
| const getChildrenAsText = children => { | ||
| return React.Children.map(children, child => { | ||
| let textContent = []; | ||
|
|
||
| React.Children.map(children, child => { | ||
| if (typeof child === 'string') { | ||
| return child; | ||
| return textContent.push(child); | ||
| } | ||
|
|
||
| if (typeof child === 'number') { | ||
| return child.toString(); | ||
| return textContent.push(child.toString()); | ||
| } | ||
|
|
||
| return ''; | ||
| if (child.props.children) { | ||
thymikee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const { children } = child.props; | ||
|
|
||
| if (children instanceof Array) { | ||
|
||
| children.forEach(node => { | ||
| // eslint-disable-next-line | ||
| const { Text } = require('react-native'); | ||
|
||
| if (filterNodeByType(node, Text)) { | ||
| return textContent.push(node.props.children); | ||
| } | ||
| }); | ||
| } else { | ||
| if (typeof children === 'string') { | ||
| return textContent.push(children); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| return textContent; | ||
| }; | ||
|
|
||
| const getTextInputNodeByPlaceholder = (node, placeholder) => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.