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

177
Views
Select input is not showing value when using map function

Im trying material ui select but it is not working as i would like to. it is not showing the default value when i use the map function but it does when using the traditional way.

*** The way which is working ***

<Select
              id="standard-select-categories"
              defaultValue="UK"
              label="Select Country"
              name="country"
              select
              variant="standard"
            >
             <MenuItem value="USA">
                USA
              </MenuItem>
              <MenuItem value="UK">
               UK
              </MenuItem>
              <MenuItem value="Japon">
               Japon
              </MenuItem>

            </Select>

input shows UK as the selected country by default

*** The way which is NOT working ***

<Select
              id="standard-select-categories"
              defaultValue="UK"
              label="Select Country"
              name="country"
              select
              variant="standard"
            >

              {Countries_Flags.map((option) => (
                <MenuItem 
                key={option.name}
                value={option.name}
                >
                  {<img src={option.flag} alt={option.name} className="select-country-items" />}
                  {option.name}

                </MenuItem>
              ))}
            </Select>

input doesnt show UK as the selected country by default

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

The value being assigned to the MenuItem needs to match the value you set for the defaultValue prop on the select.

eg: [{name:"United Kingdom"}] . "United Kingdom" should be the defaultValue

        <Select
          id="standard-select-categories"
          defaultValue="United Kingdom"
          label="Select Country"
          name="country"
          select
          variant="standard"
        >
          // "United Kindom" for the defaultValue prop
          <MenuItem value={"United Kindom"}>UK</MenuItem>
          // "United States of America" for the defaultValue prop
          <MenuItem value={"United States of America"}>USA</MenuItem>
        </Select>
about 4 years ago · Santiago Gelvez 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!