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

120
Views
Use array to render select options

This should be straitforward thing but I cannot get to work even i tried different apporaches and also refered the stackoverflow existing solutions. I'm new to frontend work. I have react app (using typescript) and I'm using antd componets. I have following object

class User {
     locations: Location[];
}
class Location {
      name:string;
}

I want to render location names in select options. I tried

      <Select
            id="location"
            placeholder="Location"
          >
            {user.locations.map((loc) => {
              console.log('got -> ' + loc.name);
              <Option value={loc.name}>{loc.name}</Option>;
            })}
          </Select>

I get the exepected console log but nothing is rendered ( empty options list ) and there is no error. How to get this working

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You aren't returning anything from your map function, so it's just running and returning void. Since no component is returned, none is rendered. If you have multiple lines of code in an arrow function you have to use an explicit return. To quote MDN, (arrow functions do not magically guess what or when you want to "return")

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions

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!