Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
when I try to click on the image then this error will show:- undefined is not an object (evaluating 'navigation.navigate') (Device) I want to that when I click on the image then details page is open


Project URL:-
snack.expo.dev/@akhireact/travelappui 

Page location:- ./component/Home.js


Please check I try everything but I don't have any solution

I am waiting for your response

Thank You

What I have tried:

const Home = ({navigation}) => {
  
  const renderDiscoverItem = ({item}) => {
    return (
      <TouchableOpacity
        onPress={() =>
         navigation.navigate('Details', {
            item: item,
          })
        }>
        <ImageBackground
          source={item.images}
          style={[
            styles.discoverItem,
            {marginLeft: item.id === 'discover-1' ? 20 : 0},
          ]}
          imageStyle={styles.discoverItemImage}>
          <Text style={styles.discoverItemTitle}>{item.title}</Text>
          <View style={styles.discoverItemLocationWrapper}>
            <Entypo name="location-pin" size={18} color={colors.white} />
            <Text style={styles.discoverItemLocationText}>{item.location}</Text>
          </View>
        </ImageBackground>
      </TouchableOpacity>
    );
  };
Posted
Comments
Luc Pattyn 30-Dec-21 10:34am    
I think you should remove the comma in
item: item,
IG Techso 30-Dec-21 23:32pm    
Hi Problem already solved there is navigation problem

Now I used useNavigation then it was working fine

Thank You

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900