Unexpected behavior for <Text /> element
See original GitHub issueIn React Native it is okay to pass a number as a child for a <Text />
element. So
<Text>2<Text />
is the same as
<Text>{"2"}<Text />
or
<Text>2.toString()<Text />
But since getByText
only accepts a string as it’s input, you can’t find the element if it’s being rendered in the first way.
This took me quite some time to debug and I think it’s very counter-intuitive. Maybe there is a good solution so getByText
finds everything rendered between <Text />
tags?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Accessing the text node of an element - unexpected behavior (for ...
I'm trying to access the text of some elements using jquery, but it seems that once the text is accessed, it is removed...
Read more >Unexpected behavior with inline-block - Stack Overflow
You made your element to behave like an inline element so there is no more line break and thus you will have this...
Read more >SharePoint 2010 rich-text editor unexpected behavior
In Microsoft Word, a newline immediately following a heading reverts to normal text. The same is true of the RTE in Google Docs....
Read more >Unexpected Behavior of Text Input node - Dashboard
The issue arises when the user stops the reaction, or tries to modify a parameter. When this happens, only the modified value is...
Read more >oxy_textArea Unexpected Behavior/Not Working in Oxygen ...
As far as I understand you use the textfield to edit the value of an attribute, and for some reason the text content...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
~~I tried that way, too ~~
and still the component isn’t found.I’m sorry, I’m dumb, this works. Thank you a lot!
If someone in the future sees that: If you have a
prop
namedamount
make sure to use it like this:instead of this:
Otherwise the regex above will not find it 😄
Awesome you made it!