import React, { useEffect, useRef } from "react"; import { FlatList, View } from "react-native"; import { Message } from "../../types"; import { MessageBubble } from "./MessageBubble"; interface MessageListProps { messages: Message[]; } export function MessageList({ messages }: MessageListProps) { const listRef = useRef>(null); useEffect(() => { if (messages.length > 0) { // Small delay to allow layout to complete setTimeout(() => { listRef.current?.scrollToEnd({ animated: true }); }, 50); } }, [messages.length]); return ( item.id} renderItem={({ item }) => } contentContainerStyle={{ paddingVertical: 12 }} onContentSizeChange={() => { listRef.current?.scrollToEnd({ animated: false }); }} showsVerticalScrollIndicator={false} ListFooterComponent={} /> ); }