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

315
Vistas
Passing a list of values between pages in react native

I am new to React/React-native. I am trying to add a key-value pair in the JSON body which is the output of screen 1 having the following components:

  1. A textbox which is to input a name
  2. A textbox which is to input an email
  3. A button, Types that navigates to Screen 2

The components on screen 2 are:

  1. Two single-option dropdown lists with labels type 1 and type 2 that have three options each- "a", "b", "c".
  2. A SAVE button to save the options chosen.

Initially, the JSON data produced from screen 1 WITHOUT the functionality of the Types button was:

body: JSON.stringify({
name: Name,
email: Email})

but now I want the output from screen 1 to be:

body: JSON.stringify({
name: Name,
email: Email,
types:[type1:"a", type2:"b"]
})

where type1 and type2 are the labels of the two dropdown lists and the options selected are "a" and "c" respectively after pressing a SAVE button on screen 2 and then navigating to screen 1. I have used the following useState methods for name and email for screen1:

const [Name, setName] = useState("")
const [Email, setEmail] = useState("")

and after making Types as a functional button on screen 1:

const [Name, setName] = useState("")
const [Email, setEmail] = useState("")
const [Types, setTypes] = useState([])

The below code is to update the name and the email with a Types button on screen 1:

<TextInput
label='Name'
value={Name}
onChangeText={text => setName(text)}
/>

<TextInput
label='Email'
value={Email}
onChangeText={text => setEmail(text)}
/>

<Button onPress={() => navigation.navigate("screen_2")>
Types
</Button>

What should be my onPress function in the button, Types(Screen 1) and button, Save(Screen 2) and how do I update the JSON body after saving my options on screen 2?

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

0

If you're using something like React Router, you should check how to pass state with it. If not you might want to create a Redux store to save state relevant to the whole application

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