vendredi 21 août 2020

Random image after click onclass react-native

my code is not working and my photo is not displayed. I try different options but I don’t get it. Maybe you know what this could be too problematic?

const images= [
  image2 = './assets/images/geltonas_trikampis.png',
  image3 = './assets/images/zalias_trikampis.png',
  image4 = './assets/images/juodas_trikampis.png',
  image6 = './assets/images/raudonas_trikampis.png',
  ];

  changeImage = () => {
    console.log('Working');
    const randomNumber = Math.floor(Math.random() * images.length);
    this.setState({
      currenturiImageIndex: randomNumber,
    });
  }
  
  <TouchableOpacity onPress={()=> this.changeImage()}>
      <Image
    source={this.state.currenturiImageIndex}
    style={styles.logoStyle}
  /></TouchableOpacity>

I get the result on the console, but I don't show the photo and I don't know what else might be after the click.

I really appreciate the help.




Aucun commentaire:

Enregistrer un commentaire