Javascript 错误:TypeError:undefined在使用flalist时不是对象(评估';tem.userName';)

Javascript 错误:TypeError:undefined在使用flalist时不是对象(评估';tem.userName';),javascript,reactjs,react-native,Javascript,Reactjs,React Native,我对本地平面列表有问题 flatlis不渲染 我该怎么办 以下是代码。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 ..................................................................... 代码如下所示: import React,{useState,useffect}来自“React”; 从“@react native as

我对本地平面列表有问题 flatlis不渲染
我该怎么办 以下是代码。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。 ..................................................................... 代码如下所示:

import React,{useState,useffect}来自“React”;
从“@react native async storage/async storage”导入异步存储;
进口{
样式表,
看法
文本,
文本输入,
安全区域视图,
滚动视图,
警觉的,
按钮
键盘避免了gView,
平台,
许可证Sandroid,
平面列表,
}从“反应本机”;
从“@react native community/Geolocation”导入地理位置;
常量应用=()=>{
常数员额=[
{
id:'1',
用户名:'Jenny Doe',
发帖时间:“4分钟前”,
职位:
“嘿,这是我在React Native中发布社交应用程序的测试。”,
喜欢:是的,
喜欢‘14’,
评论:“5”,
},
{
id:'2',
用户名:“John Doe”,
发帖时间:“2小时前”,
职位:
“嘿,这是我在React Native中发布社交应用程序的测试。”,
喜欢:错,
喜欢‘8’,
注释:“0”,
},
{
id:'3',
用户名:“肯·威廉”,
发帖时间:“1小时前”,
职位:
“嘿,这是我在React Native中发布社交应用程序的测试。”,
喜欢:是的,
喜欢:“1”,
注释:“0”,
},
{
id:'4',
用户名:“Selina Paul”,
发帖时间:“1天前”,
职位:
“嘿,这是我在React Native中发布社交应用程序的测试。”,
喜欢:是的,
喜欢‘22’,
评论:‘4’,
},
{
id:'5',
用户名:“Christy Alex”,
发帖时间:“2天前”,
职位:
“嘿,这是我在React Native中发布社交应用程序的测试。”,
喜欢:错,
喜欢:“0”,
注释:“0”,
},
];
常量renderItem=({tem})=>{
{tem.userName}
{tem.post}
};
返回(
tem.id}
/>
);
};
const styles=StyleSheet.create({
容器:{
paddingTop:23,
},
输入:{
差额:15,
边框颜色:“#7a42f4”,
边框宽度:1,
},
提交按钮:{
背景颜色:“灰色”,
填充:10,
差额:15,
身高:40,
宽度:10,
},
submitButtonText:{
颜色:'白色',
},
按钮容器:{
宽度:“40%”,
对齐自我:“中心”,
时间:30,,
颜色:“红色”,
},
});
导出默认应用程序;

您应该使用预定义的
项,而不是
tem
。另外,似乎缺少
return

const renderItem=({item})=>{
返回(
{item.userName}
{item.post}
);
};
import React, {useState, useEffect} from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import {
  StyleSheet,
  View,
  Text,
  TextInput,
  SafeAreaView,
  ScrollView,
  Alert,
  Button,
  KeyboardAvoidingView,
  Platform,
  PermissionsAndroid,
  FlatList,
} from 'react-native';
import Geolocation from '@react-native-community/geolocation';

const App = () => {



  const Posts = [
    {
      id: '1',
      userName: 'Jenny Doe',
                postTime: '4 mins ago',
      post:
        'Hey there, this is my test for a post of my social app in React Native.',
      liked: true,
      likes: '14',
      comments: '5',
    },
    {
      id: '2',
      userName: 'John Doe',
      postTime: '2 hours ago',
      post:
        'Hey there, this is my test for a post of my social app in React Native.',
      liked: false,
      likes: '8',
      comments: '0',
    },
    {
      id: '3',
      userName: 'Ken William',
      postTime: '1 hours ago',
      post:
        'Hey there, this is my test for a post of my social app in React Native.',
      liked: true,
      likes: '1',
      comments: '0',
    },
    {
      id: '4',
      userName: 'Selina Paul',
      postTime: '1 day ago',
      post:
        'Hey there, this is my test for a post of my social app in React Native.',
      liked: true,
      likes: '22',
      comments: '4',
    },
    {
      id: '5',
      userName: 'Christy Alex',
      postTime: '2 days ago',
      post:
        'Hey there, this is my test for a post of my social app in React Native.',
      liked: false,
      likes: '0',
      comments: '0',
    },
  ];



  const renderItem = ({tem}) => {

    <View style={styles.item}>
      <Text style={styles.title}>{tem.userName}</Text>
      <Text style={styles.title}>{tem.post}</Text>
    </View>
  };
    
  return (
   
    <View>
  
      <FlatList
        data={Posts}
        renderItem={renderItem}
        keyExtractor={(tem) => tem.id}
      />

              </View>
  );
};

const styles = StyleSheet.create({
  container: {
    paddingTop: 23,
  },
  input: {
    margin: 15,

    borderColor: '#7a42f4',
    borderWidth: 1,
  },
  submitButton: {
    backgroundColor: 'gray',
    padding: 10,
    margin: 15,
    height: 40,
    width: 10,
  },
  submitButtonText: {
    color: 'white',
  },
  buttonContainer: {
    width: '40%',
    alignSelf: 'center',
    marginVertical: 30,
    color: 'red',
  },
});

export default App;