Home > other >  React image redirect to another page when click on it in react native
React image redirect to another page when click on it in react native

Time:05-28

Here is my code. It is not working. I want that if anyone clicks on this image it will move to the men's category page.

<TouchableOpacity >
       <Image source={require("../assets/mens.png")} style={{ width: 50, height: 50, borderRadius: 20 }} onPress={() => navigation.navigate(MensCategory)}/>
       </TouchableOpacity>
      </View>

CodePudding user response:

onPress callback should be applied to TouchableOpacity component. Move it to there from Image.

CodePudding user response:

<TouchableOpacity onPress={()=> // Move function call}>
<Image source={require("../assets/mens.png")} style={{ width: 50, height: 50, borderRadius: 20 }} onPress={() => navigation.navigate(MensCategory)}/>
</TouchableOpacity>

Above, i Mention the Logic, Try Again Move it to respective page

CodePudding user response:

Maybe you need to pass a string on navigate method. So its like,

() => navigation.navigate("MensCategory")
  • Related