I'm trying to loop through a simple array inside a functional component so it returns list of names inside the array. The error I get is Person(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
const Person = () => {
var persons = ["John", "Ron"];
persons.map(p => {
return (
<div>
<ul>
<li> I am {p} </li>
</ul>
</div>
)
})
}
persons.map(p => (( <div ... </div> ));since it's technically a single line return statement