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

166
Visualizações
How to prefilled data in form and the form is editable by using react functional component

This is my react jsx file code overview

const [name, setName] = useState("");
// and the prefield data which I want to be prefield is commit from API which is 
const nameFromApi = userDatails?.name;

// Here is my function return JSX
<input defaultValue={nameFromApi}  value={name} onChange={e => setName(e.target.value)} />
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can initialize name with the value so that will be the initial value of the input

const [name, setName] = useState(userDatails?.name);

<input value={name} onChange={e => setName(e.target.value)} />

about 4 years ago · Juan Pablo Isaza Relatório

0

If I understand correctly, you are getting a respone from api which is userDatails and you want your input to have the value if userDatails as its initial value?

You can do something like this

const [name, setName] = useState("");

useEffect(()=>{

//call your api and get value

...

setName(userDatails?.name)

},[])
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