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

236
Visualizações
Can't edit input value in React

I work on a project in React and I have an input in a table for quantity of a product I want to buy and I can't change the value on the web page.

If I delete value property, I can modify the value and I think I type something wrong. Cand somebody help me how to type that value property to be 1?

                       <input
                          type="text"
                          id={"cantitate_" + index}
                          value={1}
                          onChange={(e) => changeQuantity(e.target.value, index)}
                        />

changeQuantity is a function where I try to calculate something.

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

0

You should be using defaultValue instead of value, since I assume from the comment that you are not implementing a controlled form:

  <input
    type="text"
    id={"cantitate_" + index}
    defaultValue={1}
    onChange={(e) => changeQuantity(e.target.value, index)}
  />
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