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
React Native no muestra la imagen correcta

Estoy tratando de hacer una presentación de diapositivas donde el usuario pueda reproducirlas en un orden predeterminado o aleatorio y recorrerlas presionando un botón. El problema viene cuando el usuario ha elegido el modo aleatorio; al presionar el botón aún se incrementa la variable índice actual, pero por alguna razón, las imágenes [índice actual] no cambian.

 const SlideshowScreen = (props) => { const settings = props.route.params.settings; const [images, setImages] = useState(settings.random ? props.route.params.images.sort((a, b) => 0.5 - Math.random()) : props.route.params.images); const [currentIndex, setCurrentIndex] = useState(0); useEffect(() => { console.log('currentIndex', currentIndex, images[currentIndex]); }, [currentIndex]) const newImage = () => { if (currentIndex + 1 >= images.length) { console.log('done'); } else { setCurrentIndex(currentIndex + 1); } } return ( <View style={styles.mainContainer}> <View style={styles.imageContainer}> <Image style={styles.image} source={images[currentIndex].path} key={images[currentIndex].id} /> </View> <TouchableOpacity onPress={() => newImage()}> <Text>Next image</Text> </TouchableOpacity> </View> ) }

En algunos clics del botón esto sucede, y en otros no. ¿Cómo está pasando esto? Cualquier ayuda sería genial, gracias.

about 4 years ago · Juan Pablo Isaza
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!