import * as React from "react"; import { StyleSheet } from "react-native"; import EditScreenInfo from "../components/EditScreenInfo"; import { Text, View } from "../components/Themed"; import type { Conversation } from "../../api/src/controller/sms"; export default function TabTwoScreen() { const [conversations, setConversations] = React.useState({}); const conversationsEntries = Object.entries(conversations); React.useEffect(() => { fetch("http://192.168.1.40:3000/conversations") .then(response => response.json()) .then(conversations => setConversations(conversations)) .catch(error => console.error("error", error)); }, []); return ( Tab Two {conversationsEntries.map(([recipient, messages], index) => { const lastMessage = messages[messages.length - 1]; return ( <> {recipient} {lastMessage.content} {new Date(lastMessage.sentAt).toDateString()} {index + 1 < messages.length && ( )} ) })} ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: "center", justifyContent: "center", }, title: { fontSize: 20, fontWeight: "bold", }, separator: { marginVertical: 30, height: 1, width: "80%", }, });