DEV Community

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

Posted on • Edited on

4

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💻

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

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.

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay