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

93
Views
Modal no se abre al hacer clic en la imagen del componente de la galería

Estoy tratando de abrir un modelo cuando hago clic en el componente de imagen en la galería. Aquí no obtengo la variable "flagImage" actualizada en el método onPress de TouchableOpacity o el componente modal no obtiene el valor actualizado de "flagImage" cuando onPress of TouchableOpacity cambia su valor. Necesito ayuda aquí. El modal no se abre en absoluto cada vez que toco el componente de la imagen. Simplemente no hace nada :( A continuación se muestra el código de gallery.component.js:

 import React from 'react'; import { View, Image, ScrollView, TouchableOpacity, Modal, Text } from 'react-native'; import styles from './cameraStyles'; export default ({captures=[], flagImage=true}) => ( <ScrollView horizontal={true} style={[styles.bottomToolbar, styles.galleryContainer]} > {captures.map(({ uri }) => ( <View style={styles.galleryImageContainer} key={uri}> <TouchableOpacity onPress={()=> { flagImage = !flagImage; console.log('Touch: "'+flagImage+'"'); }} > <Image source={{ uri }} style={styles.galleryImage}/> </TouchableOpacity> <Modal visible={flagImage} onPress={() => {console.log('Modal: "'+flagImage+'"');flagImage = !flagImage;}} onRequestClose={() => flagImage = ! flagImage}> <View> <Image source={{ uri }} style={styles.galleryImageLarge}/> </View> </Modal> </View> ))} </ScrollView> );
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede utilizar el gancho useState para convertir los accesorios en un estado en el que pueda actualizarlos.

 import React from 'react'; import { View, Image, ScrollView, TouchableOpacity, Modal, Text } from 'react-native'; import styles from './cameraStyles'; export default ({captures=[], lflagImage=false}) => { const [flagImage, setflagImage] = React.useState(lflagImage); return ( <ScrollView horizontal={true} style={[styles.bottomToolbar, styles.galleryContainer]} > {captures.map(({ uri }) => ( <View style={flagImage?styles.galleryImageContainer:styles.galleryImageContainerView} key={uri}> <TouchableOpacity onPress={()=> { setflagImage(prevData => !prevData) console.log('Touch: "'+flagImage+'"'); }} > <Image source={{ uri }} style={flagImage?styles.galleryImage:styles.galleryImageLarge}/> </TouchableOpacity> <Modal visible={flagImage} onRequestClose={() => setflagImage(prevData => !prevData)}> <View> <Image source={{ uri }} style={styles.galleryImageLarge}/> </View> </Modal> </View> ))} </ScrollView> ) }
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!