Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
Map function creating unwanted values

My function currently is creating multiple buttons with the map function when i'm trying to just map the URL of the ID. how do I change this?

              <NavBtn>
                {data.map((user) => (
                  <div key={user._id}>
                    <NavBtnLink to={`/account/${user._id}`}></NavBtnLink>
                  </div>
                ))}
              </NavBtn>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

What's the value of data? It's probably got more than one user in. Map transforms every value of an array to another value.

If you just wanted the first user you could do:

<NavBtn>
    {data.find(element => element).map((user) => (
        <div key={user._id}>
            <NavBtnLink to={`/account/${user._id}`}></NavBtnLink>
        </div>
     ))}
</NavBtn>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!