Hello Everyone,
I’m doing the React Native Fundamentals course and am stuck at Input Components - Lesson 3.
Am facing an error message which I have no idea where is it located, let alone know how to troubleshoot. Screenshot of the error message is below.
Here are my codes for App.js (hastebin ), and AppTextInput.js(hastebin ).
Any help will be much appreciated. Thanks!
dpickut
February 12, 2021, 3:13pm
2
Your code looks pretty clean. I noticed one thing you might try. In line 11, try adding ( ) around the MaterialCommunityIcon component:
{icon && ()}
The compiler parser might be getting confused with that line of JSX.
Thanks @dpickut for reaching out.
I’ve wrapped the component in ().
{icon && (<MaterialCommunityIcons name={icon} /> )}
However, the error message is still the same.
dpickut
February 12, 2021, 4:18pm
4
Sorry that didn’t work. The error message is saying that the parser is somehow encountering something to be rendered that it sees as a text string – but not inside a component.
If you can’t find a a syntax error in your code, you might try doing a restart of the dev server, then reload the code in the Expo app in the simulator. (That’s worked for me a few times throughout this course.)
I found the cause of the error… and it was a very silly mistake from me.
There was a ; in the return statement.
return (
<Screen>
<AppTextInput />;
</Screen>
)
Thanks again @dpickut for following up with my thread, and explaining what the error meant . Now my AppTextInput works.
dpickut
February 13, 2021, 2:49pm
6
Glad you got it solved! I’ve made the same mistake myself – more than once.
1 Like
tanzhiz
September 15, 2022, 4:53pm
7
Thank you, I have make the same mistake,and now it solved.