I was facing a problem: my navlinks do not show on screen. I used YouTube for how to organise navlinks using the map method, but it was not working. So I asked Agent AI, "What is the problem with my code?" It gave me this code: {navLinks.map((link, idx) => { I only did not write return.
return <a href={link.href} key={idx}>{link.label}</a>;
})}
***Why*: I asked AI, why when I use return on the link, it works:-
_Because of how JavaScript arrow functions work:
With curly braces {} → requires explicit return:
With parentheses () → implicit return (no return keyword needed):
If you used => {( instead of just => (, that's why it failed. The parentheses must come directly after => with no braces before them._
*That's why.
*
Top comments (0)