React native React本机平面列表错误:对象作为React子对象无效
一旦我添加了超过1条评论,我就会得到这个错误。我猜最新版本的react native存在一些语法问题,因为它无法读取注释数组。请帮忙React native React本机平面列表错误:对象作为React子对象无效,react-native,react-native-flatlist,React Native,React Native Flatlist,一旦我添加了超过1条评论,我就会得到这个错误。我猜最新版本的react native存在一些语法问题,因为它无法读取注释数组。请帮忙 <FlatList refreshing={this.state.refresh} data={this.state.comments_list} keyExtractor={(item, index) => index.toString()}
<FlatList
refreshing={this.state.refresh}
data={this.state.comments_list}
keyExtractor={(item, index) => index.toString()}
style={{ flex: 1, backgroundColor: "#eee" }}
renderItem={({ item, index }) => (
<View key={index} style={styles.flatListViewItems}>
<View style={{ padding: 5, width: "100%", flexDirection: "row", justifyContent: "space-between" }}>
<Text>time :{item.posted}</Text>
<TouchableOpacity
onPress={() =>
this.props.navigation.navigate("User", {
userId: item.authorId
})
}
>
<Text style={{ paddingRight: 5 }}>{item.author}</Text>
</TouchableOpacity>
</View>
<View style={{ padding: 5 }}>
<Text>{item.comment}</Text>
</View>
</View>
)}
/>
文本组件无法渲染对象。就像错误显示的那样。 尝试更改此行:
<Text style={{ paddingRight: 5 }}>{item.author}</Text>
{item.author}
此错误表示正在渲染文本中的对象。它应该是原始文本。尝试控制台。警告(项目)
并查看正在渲染的对象。你有那些属性吗。
<Text style={{ paddingRight: 5 }}>{item.author}</Text>