DEV Community

Cover image for React Native error Text strings must be rendered within a <Text> component (Solution)
Osman Forhad
Osman Forhad

Posted on • Updated on

React Native error Text strings must be rendered within a <Text> component (Solution)

Alt Text
so the error is "Text strings must be rendered within a component"
.
I have done everything well but my virtual device and terminal show me:
Text strings must be rendered within a component
error.
.
in this case, I was trying to find out what I did wrong actually. after some time I got wrong what actually I did.
.
it occurred because I made a comment in a render function. which is like the below screen-shot:
Alt Text
to solve this error I remove this comment from the render function which is like the below screen-shot:
Alt Text
and then it's working nicely:
and here is my output both terminal and virtual device:
Alt Text
Now the problem is solved.
but I have more curiosity why I can't write any comment in render function to clarify this, I tried to another way. which is like the below screen-shot:
Alt Text
now I can able to write a comment to render a function like this method.
.
now it time to try another method and it's not working which is like the below screen-shot:
Alt Text
.
so finally I understand that either I should not write any comment in a render function
.
or
I have to comment like the below procedure:
Alt Text
.
the problem is solved and understand more clearly why it happens and how to solve this.
thats it.
.
Happy Coding.
osman forhad
Mobile & Web Application Developer💻

Top comments (3)

Collapse
 
quantuminformation profile image
Nikos • Edited

pretty dumb framework then

Collapse
 
agrit_tiwari profile image
Agrit tiwari

I checked this approach, but didn't seem to solve my issue!

Collapse
 
cyebukayire profile image
Peace

Hi, what was your case?
I'm using inside my but am getting this issue. When I remove the Button, everything works.