如何解决渲染错误:无法读取 React Native 上未定义的属性“名称”

问题描述 投票:0回答:0

这是我第一次编码,我遇到了渲染错误。将不胜感激任何形式的反馈。

从“反应”导入反应; 从 'react-native' 导入 {Text, ImageBackground, View, StyleSheet};

const Card = props => { const {name, image, bio} = props.user; 返回 (

     <Text style={styles.name}>{name}</Text>
     <Text style={styles.bio}>{bio}</Text>
     </View>
     </ImageBackground>
   </View>
   );
 };

 const styles = StyleSheet.create({
    card: {
      width: '95%', 
      height: '70%', 
      borderRadius: 10, 
  
      shadowColor: "#000",
      shadowOffset: {
        width: 0,
        height: 6,
      },
      shadowOpacity: 0.37,
      shadowRadius: 7.49,
      
      elevation: 12,
    },
    image: {
        width: '100%', 
        height: '100%',
        borderRadius: 10, 
        overflow: 'hidden',
  
        justifyContent: 'flex-end',
      },
      cardInner: {
        padding: 10, 
  
      },
    name: {
        fontSize: 30,
        color: 'white', 
        fontWeight:'bold'
      },
    bio: {
        fontSize: 18, 
        color: 'white',
        lineHeight: 25, 
      },
    });

导出默认卡;

我在 iOS 模拟器上运行这段代码,这是我看到的错误。 Render Error - Cannot read property 'name' of undefined

非常感谢任何帮助。我对此非常陌生,所以如果你能用更简单的术语向我解释,那就太好了<3

ios react-native undefined
© www.soinside.com 2019 - 2024. All rights reserved.