Redirect to another page when pressing an image in React Native

Viewed 55

I'm trying to make it redirect to another page when the image is pressed but it seems like it does nothing though it shows an animation of the image being pressed but that's it

here is my code

        <View style={styles.box}>
            <TouchableOpacity style={styles.inner} >
                <Image source={require('./1.png' )} onPress = {() => navigation.navigate('First')}/>
            </TouchableOpacity>
        </View>

I also tried moving the OnPress to the TouchableOpacity and it gives me an error "can't find variable: navigation"

1 Answers

Add onPress function to TouchableOpacity instead of Image.
onPress does not exist on Image.

Related