Enable message reply support in Chatty
To enable reply support in the
Chatty component, you must manage the state of the message being replied to. Use the onReply prop to capture the message the user wants to reply to and the replyingTo prop to pass that message object back into the component for display.import React, { useState } from 'react';
import { Chatty } from 'react-native-chatty';
export default function MyReactPage() {
const [messages, setMessages] = useState([]);
const [replyingTo, setReplyingTo] = useState(null);
return (
<Chatty
messages={messages}
// Handle onreply event and store the message in state
onReply={(message) => setReplyingTo(message)}
// Provide the message object currently being replied to
replyingTo={replyingTo}
headerProps={{
id: 0,
username: "Muhammed Kaplan",
avatar: { uri: "https://blalala.com" }
}}
footerProps={{
onChangeText: (text) => { /* handle text change */ },
onPressSend: (data) => { /* handle send */ }
}}
/>
);
}