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

198
Visualizações
How can we send JSX Element as radio button in MUI Autocomplete render options

I am using the MUI Autocomplete. And here is the code am sending a JSX Element[] with radio buttons.

Tryout.JSX

const [selectedValue, setSelectedValue] = React.useState('a');
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
setSelectedValue(event.target.value);
 };

<AutoCompleteSelect
    optionsData={[
      {
        text: 'Last month',
        element: (
          <div>
            {' '}
            <Radio
              checked={selectedValue === 'a'}
              testid="testRadioWrapper"
              value={'a'}
              onChange={(event) => handleChange(event)}
            />
            a
          </div>
        ),
      },
      {
        text: 'Last 10 month',
        element: (
          <div>
            {' '}
            <Radio
              checked={selectedValue === 'b'}
              testid="testRadioWrapper"
              value={'b'}
              onChange={(event) => handleChange(event)}
            />
            b
          </div>
        ),
      },
    ]}
  />

Receiving optionsData props to Autocomplete.jsx file.

Autocomplete.JSX

 <Autocomplete
      disablePortal
      id="single-select"
      options={optionsData}
      data-testid={testid}
      getOptionLabel={(option) => option.text}
      open={true}
      autoHighlight={false}
      disableClearable
      renderOption={(props, option, { selected }) =>
      <MenuItem {...props}>{option.element}</MenuItem>  
      }
      popupIcon={
        showList ? (
          <i
            className="icon-UpAlternative"
            aria-hidden="true"
            style={{
              fontSize: 11,
              color: Skin.colors.blackLight.value,
            }}
          ></i>
        ) : (
          <i
            className="icon-DownAlternative"
            aria-hidden="true"
            style={{
              fontSize: 11,
              color: Skin.colors.blackLight.value,
            }}
          ></i>
        )
      }
      renderInput={(params) => (
        <TextField
          {...params}
          label=""
          placeholder=""
          data-testid="inputSearchFilter"
        />
      )}
    />

While rendering the options and clicking the radio button inside the list is giving a run time error. enter image description here

Does anyone know why this happens?

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