Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
renderValue prop not working in MUI native Select

When I set the the native prop in MUI Select component, the renderValue prop doesn't work. Also, if I try to pass a custom value to the value prop, it doesn't appear. Here is the code:

const [selectValue, setSelectValue] = useState(null);

const handleTargetDataChange = (event) => {
   const { value, selectedIndex} = event.target;
   const label = options[selectedIndex].parentElement.getAttribute("label");
   setSelectValue(`${label} - ${event.target.value}`);
}

            <FormControl>
              <Select
                native
                id="export-to-select"
                sx={{ borderRadius: "0px" }}
                inputProps={{ sx: { padding: "0.5rem" } }}
                value={selectValue}
                onChange={handleTargetDataChange}
                renderValue={(value) => (value ? value : <em>Nothing</em>)}
                IconComponent={CustomSelectIcon}
                displayEmpty
              >
                <option aria-label="None">Select target</option>
                {targetData.map(
                  (target) =>
                    (
                      <optgroup label={target.name}>
                        {target.platforms.map((platform) => (
                          <option value={platform.name}>{platform.name}</option>
                        ))}
                      </optgroup>
                    )
                )}
              </Select>
            </FormControl>

I want the value that is shown to be ${label} - ${event.target.value}, but the Select component displays the value in the default way. How can I modify its standard behavior?

When there is no value, I want the renderValue prop to display the string Nothing. This doesn't work either.

Note: if I remove the native prop, it shows the value that I want, but it messes up the formatting of the drop down menu items.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda