I'm currently creating a small Magic the Gathering project which fetches card data from an API and inserts it in my app. I fetched the data like name and such first, but then when I click on the name I want to see more information such as card description and such. However, I keep running into the problem where I get the error “undefined is not an object (this.props.navigation.navigate)”. How do I fix this?
import React from 'react';
import { Paragraph, Card, Avatar, Button } from "react-native-paper";
import { Image, View, StyleSheet, AsyncStorage } from 'react-native';
export default class CardProfile extends React.Component {
render() {
const { props } = this.props
const card = props["state"].params
const img = card.imageUrl
return (
<View style={styles.container}>
<View style={styles.cardinfo}>
<Card>
<View style={styles.title}>
<Card.Title
title={card.name}
subtitle={card.colors}
/>
</View>
<View style={styles.content}>
<Card.Content>
<Paragraph>{card.text}</Paragraph>
<Image
style={styles.img}
source={{ uri: img }}
/>
</Card.Content>
</View>
<View style={styles.actions}>
<Card.Actions>
<Button onPress={() => {
// create a function that saves your data asyncronously
_storeData = async () => {
try {
await AsyncStorage.setItem('@Card', this.state.card);
} catch (error) {
console.log("Could not save!", error);
}
}
}}>add card</Button>
</Card.Actions>
</View>
</Card>
</View>
</View>
);
}
}
The output should be the card information for the selected card I wanted to see.