Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

313
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!