function MessagesScreen(props) {
const [messages, setMessages] = useState(initialMessages);
const [refreshing, setRefreshing] = useState(false);
const handleDelete = (message) =>{
setMessages(messages.filter((m) => m.id !== message.id));
}
//handleDelete is not working
return (
<SafeAreaView style={styles.screen}>
<FlatList
data={initialMessages}
keyExtractor={initialMessages => initialMessages.id.toString()}
renderItem={({item}) => (
<ListItem
title={item.title}
subTitle={item.description}
image={item.image}
onPress ={() => console.log("Message selected", item)}
renderRightActions={ () =>
<ListItemDeleteAction onPress={() =>handleDelete(item)}/>}
/>)}
ItemSeparatorComponent={ListItemSeparator}/>
refreshing={refreshing}
onRefresh={() => {
setMessages([
{
id: 1,
title: "text1",
description: "String1",
image: require("../assets/axl.png"),
},
])
}
}
</SafeAreaView>
);
}
![error1|690x132](upload://q5TfozwZ3xFGbRevrOEBRdUUb41.png)
![error2|690x214](upload://tB3Vfh0kbYIJfWILcMXOBF1hZai.png)
In your MessagesScreen
component, you’re trying to render string without wrapping it in a <Text>
tag.