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

103
Vistas
Update multiple states via onValueChange - React Native

I have dropdown from which a user will select a value from, each of these values have a corresponding description. To populate the dropdown i retrieve the values from my database

Once a user has selected their value, I would like to update another field (so a separate state) with that corresponding description

This is how i populate the dropdown so far

 const [newEventName, setEventName] = useState('');
 const [newEventDescription, setEventDescription] = useState('');

<Select
  onValueChange={newEventName => setEventName(newEventName)}
  placeholder="Select Event"
>
{eventTypeData.map(event => (
  <Select.Item
    key={event.id}
    label={event.name}
    value={event.name}
   />
 ))}
 </Select>

Can I call two methods within my onValueChange, so i would create a custom function to handle mapping the value selected to its appropriate description, then call it within the onValueChange

Unless theres a better way?

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

0

You can just do like bellow

const updateValues = (newEventName) => {
                         // find your newEventDescription
                         setEventName(newEventName);
                         setEventDescription(newEventDescription);
                     }
onValueChange={newEventName => updateValues(newEventName)}
about 4 years ago · Juan Pablo Isaza Denunciar

0

This is pretty straightforward, create a function and write the logic to extract description from your eventName, and then set both values.

const setEventNameAndDesc = (newEventName) => {
// extract your description from the eventName
   setEventName(newEventName);
   setEventDescription(newEventDescription);
}                    
onValueChange={newEventName => setEventNameAndDesc(newEventName)}
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