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

215
Visualizações
React - useState not reflecting the updated values

I'm trying to bind a value typed by the user, in another input, which is readOnly, but it's reflecting in other input. Even though the value as I type, it can appear on html, but I'm unable to bind it to other input. Before I post this question, I already searched the SO to bind values, but most of them bind to html but not other input field, like my case

here is the codesandbox code which is causing trouble for me.

https://codesandbox.io/s/epic-bose-jr8rr

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

0

use setContactForm instead of mutating the state.

about 4 years ago · Juan Pablo Isaza Relatório

0

You can do it like this with the current implementation of Input.

  1. Get value as a prop to Input and assign to another variable call it propValue
function Input({
  ...
  ...
  value: propValue
}) {
  1. Change the value property of input as below to fall back to local value (value in Input component) if propValue is not provided.
<input
     ...
     ...
     value={propValue ?? value}
     ...
     ...
 />
  1. In App.js set the value as employeeId to the ready only input.
<Input
      label="Reflected Id"
      value={employeeId}
      ...
      ...
></Input>

Edit laughing-lewin-4t7kv

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