Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

rendering list from array in reactjs

I’m loosing my mind because I don’t understand why the list tags are not rendered in my web. Can someone see what’s wrong in the code???

import "./resultBox.css"
import { useRef } from "react"

export default function ResultBox(props){
const resultBox = useRef()
const {resultados} = props

if (resultados != undefined){

    return(
        <div ref={resultBox} id="result-box">
            <ul>
                {resultados.users.map(user => {
                    <li key={user._id}>{user.first_name}</li>
                })}
            </ul>
        </div>
    )
}

}

Thanks!!!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Like what @Dave Newton said, your map function doesn’t return anything.
Take this example from where I did a similar thing the other day

 const items = historyItems.map((item, index) =>  <HistoryItem key={index} item={item} hourlyRate={props.hourlyRate}/>);
return (<div className="main-history">
    {items}
</div>);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading