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

102
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 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