DEV Community

loading...
Cover image for Text strings must be rendered within a  component (Solution) React Native error

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

osmanforhad profile image Osman Forhad ・2 min read

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💻

Discussion (1)

pic
Editor guide
Collapse
agrit_tiwari profile image
Agrit tiwari

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