Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda