React Component Rendering Issue: Missing Return Statement

🚀 30 Days — 30 Coding Mistakes Beginners Make Day 6/30 My React component rendered… nothing 😐 No error. No crash. Just empty UI. Code looked correct: fruits.map((fruit) => { <p>{fruit}</p> }) The mistake: I used `{}` but forgot `return`. Arrow functions with `{}` require an explicit return. React received “undefined”, so nothing was rendered. Fix 👇 fruits.map((fruit) => ( <p>{fruit}</p> )) Small brackets. Big difference. Day 7 tomorrow 👀 #30DaysOfCode #reactjs #javascript #frontend #webdevelopment #codeinuse

  • No alternative text description for this image

What if we add a return in {}?

Like
Reply

To view or add a comment, sign in

Explore content categories