Skip to main content

Replying message

To enable reply support you need to provide to additional props, and everything should just work as intented.

import React, { useState } from 'react';
import { Chatty } from 'react-native-chatty';

export default function MyReactPage() {
const [messages, setMessages] = useState()
const [replyingTo, setReplyingTo] = useState()
const text = useRef()

const onPressSend = (data) => {
// Implement

socket.send(data)
}

return (
<Chatty
messages={messages}
headerProps={{
id: 0,
username: "Muhammed Kaplan",
avatar: {
uri: "https://blalala.com"
}
}}
footerProps={{
// To prevent any unnecessary re-rendering, we're using ref instead of states.
onChangeText: (_text) => text.current = _text,
onPressSend
}}
// Handle onreply event, which in this case we're storing inside a state.
onReply={(message) => setReplyingTo(message) }

// Then provide message object we stored in state.
replyingTo={replyingTo}
/>
);
}

Customize Reply drag element

import React, { useState } from 'react';
import { Chatty } from 'react-native-chatty';

export default function MyReactPage() {
const [messages, setMessages] = useState()
const text = useRef()

const onPressSend = (data) => {
// Implement

socket.send(data)
}

return (
<Chatty
messages={messages}
headerProps={{
id: 0,
username: "Muhammed Kaplan",
avatar: {
uri: "https://blalala.com"
}
}}
footerProps={{
// To prevent any unnecessary re-rendering, we're using ref instead of states.
onChangeText: (_text) => text.current = _text,
onPressSend
}}
bubbleProps={{
replyDragElement: <Image source={source} />
}}
/>
);
}