I'm trying to iterate through an array with map and display it in the React view, but it doesn't show up for me.
import React from 'react'
const Formulario = () => {
const arreglo= [1,2,3,4,5];
return (
<>
<h2>listas</h2>
{
arreglo.map((item) =>{
<h3>{item}</h3>
})
}
</>
)
}
export default Formulario
On the other hand, if it is shown to me by the console, when placing the map on the return.
arreglo.map((item) =>{
console.log(item);
})
The whole of the code in general is fine, because it shows me other elements, but the map block doesn't show me anything. It also doesn't work for me using a normal function inside map . Thank you
If the function has curly braces, use
return
If you don't have keys, you don't have to put return:
additionally, if you need to assign to another array the result because it is usually the modified array.