Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda