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

195
Vistas
How to set one State with few value of inputs

i would like to know how can i set one state with few inputs value for the example this is the state

const [userBirthday, setUserBirthday] = useState('')

there are 3 inputs, i want to get e.target.value from each one and conbain them in the state

something like that **I know the syntax actually not good but it is only to simplify my question

      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />
      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />
      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />   

`

console.log(userBirthday) == Result: 12 September 2020

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This function will do the job, you need to add the handleChange method to all the input field's prop "onChange" and you need to add the name prop to all the input fields, I added input1 for the demo.

  const handleChange = (e) => {
    const data = { ...userBirthday };
    data[e.currentTarget.name] = e.currentTarget.value;
    setUserBirthday(data);
  };



 <input type="text"
           name="input1"
           placeholder='Day'
           onChange={handleChange}
      /> 
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