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

283
Views
When I use onPress, I would like to set both these states at the same time

What I have noticed is that either one of these onPress functions works when used alone. But I want them both to happen together. How could I do it?

onPress={()=>setGroupSelected(item.groupName) setModalVisible(false)}

I want to use setGroupSelected and setModalVisible at the same time. The entire block of code that uses the above line is as follows

<FlatList    data={groups} 
             keyExtractor={item=>item.groupID.toString()}        
             renderItem={({item})=> <SelectionBoxComponent inputText={item.groupName} 
             onPress={()=>setGroupSelected(item.groupName) setModalVisible(false)}  > 
             </SelectionBoxComponent> }
                    />
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One line arrow functions return the value indicated without a return statement.

Try changing this (check the onPress function change)

<FlatList    data={groups} 
             keyExtractor={item=>item.groupID.toString()}        
             renderItem={({item})=> <SelectionBoxComponent inputText={item.groupName} 
             onPress={()=>setGroupSelected(item.groupName) setModalVisible(false)}  > 
             </SelectionBoxComponent> }
                    />

to this

<FlatList    data={groups} 
             keyExtractor={item=>item.groupID.toString()}        
             renderItem={({item})=> <SelectionBoxComponent inputText={item.groupName} 
             onPress={()=> {
              setGroupSelected(item.groupName);
              setModalVisible(false);
             }}> 
             </SelectionBoxComponent> }
                    />
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!