This works with better animation
const flatListRef = useRef<FlatList>(null); // Scroll to the end after updating messages setTimeout(() => { flatListRef.current?.scrollToEnd({animated: true}); }, 100); // Small delay to ensure the list is updated