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

218
Visualizações
MUI Input doesn't allow oninput attribute

I have an MUI Input component defined like this where the oninput (tried as onInput as well) attribute doesn't get picked by MUI

  <Input
    variant="standard"
    size="small"
    type="number"
    inputProps={{
      min: '0',
      oninput: "validity.valid||(value='');",
    }}
    onChange="validity.valid||(value='');"
  />

As the MUI doc says,

inputProps object {} Attributes applied to the input element.

And well, oninput is a valid Event attribute for the input element but on render, the underlying native HTML input element has only the min attribute defined and the oninput attribute is missing.

What is going wrong here? I even tried it with onChange but to no success.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should pass a function parameter as onInput prop instead of a string like this:

const handleOnInput = (e) => {
    //e.target.value
};

<Input
    value={val}
    variant="standard"
    size="small"
    type="number"
    inputProps={{
      min: "0",
      onInput: handleOnInput
    }}
/>

You can take a look at this sandbox for live working example.

about 4 years ago · Juan Pablo Isaza Relatório
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