Scroll to bottom
Pass showScrollToBottomButton
to the chatty instance.
Usage
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}
showScrollToBottomButton={true}
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
}}
/>
);
}
Customize button
export interface IScrollToBottomProps
extends Pick<TouchableOpacityProps, 'onPress'> {
containerStyle?: ViewStyle;
content?: JSX.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}
showScrollToBottomButton={true}
scrollToBottomProps={{
content: <Text>Go Up!</Text>
}}
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
}}
/>
);
}