react-native undefined 不是对象

react-native undefined is not an object

Error 我怎么解决这个问题 ?我收到图片中的错误。这个错误的解决方法是什么?反应本机代码=> 我怎么解决这个问题 ?我收到图片中的错误。这个错误的解决方法是什么?反应本机代码=>

const Listdesing = (props) => {
    const isDarkMode = useDarkMode();
    return(
        <TouchableOpacity onPress={() => this.props.navigation.navigate('Detail',{
            text: 'item.text',
            name: 'item.title'
          })}>
                    <ListItem
                    titleStyle={{ color: isDarkMode ? 'white' : 'black' }}
                    containerStyle={{ backgroundColor: isDarkMode ? '#1C1C1E' : '#FFFFFF' }}
                    key={props.id}
                    title={props.title}
                    rightIcon={{ name: 'chevron-right', color: isDarkMode ? 'white' : 'black' }}      
                    />  
        </TouchableOpacity>
    )}
class Direm extends Component{
state = {
    text: '',
    contact : []
};

componentDidMount() {
    this.getContacts();
}
getContacts = async () => {
    const {data: { Konular } } = await axios.get('www.site.com');
    this.setState({
        contact: Konular,
    });
    console.log(Konular)
};

renderContactItem = ({ item, index }) => {
    return(
            <Listdesing
                id={item.id}
                title={item.title}
            />
    )    
};
render(){
    return(
        <FlatList 
            renderItem={this.renderContactItem}
            keyExtractor={(item) => item.id}
            data={this.state.contact}
        />
    )
}}
const Ana = ({navigation}) => {
//const isDarkMode = useDarkMode();
return(

    <Direm /> 
)}

当您只存储 props.navigation 时,您似乎正在尝试访问 this.props.navigation,试试这个:

 const Listdesing = (props) => {
        const isDarkMode = useDarkMode();
        return(
            <TouchableOpacity onPress={() => props.navigation.navigate('Detail',{ // This should be props.navigation, not this.props.navigation
                text: 'item.text',
                name: 'item.title'
              })}>
                        <ListItem
                        titleStyle={{ color: isDarkMode ? 'white' : 'black' }}
                        containerStyle={{ backgroundColor: isDarkMode ? '#1C1C1E' : '#FFFFFF' }}
                        key={props.id}
                        title={props.title}
                        rightIcon={{ name: 'chevron-right', color: isDarkMode ? 'white' : 'black' }}      
                        />  
            </TouchableOpacity>
        )}