Skip to main content

Migrate from react-native-gifted-chat

react-native-gifted-chat draws a messaging thread and leaves streaming, Markdown and AI states to you, and recent versions need react-native-reanimated and react-native-keyboard-controller. Pro Chat covers the same thread, adds what assistants need (token-by-token Markdown, reasoning, tool calls, Stop and Retry), and uses React Native core only. For a simple messaging UI in the free library, compose MessageBubble and ChatComposer.

- import { GiftedChat } from 'react-native-gifted-chat';
+ import { Chat } from '@patine-ui/pro';

- const [messages, setMessages] = useState([]); // newest first
- const onSend = (newMessages) => setMessages((prev) => GiftedChat.append(prev, newMessages));
- <GiftedChat messages={messages} onSend={onSend} user={{ _id: 1 }} isTyping={typing} loadEarlier={hasMore} onLoadEarlier={loadMore} />
+ const [messages, setMessages] = useState([]); // oldest first
+ const onSend = (text, attachments) => setMessages((prev) => [...prev, { id: uuid(), role: 'user', text, attachments }]);
+ <Chat messages={messages} onSend={onSend} status={typing ? 'streaming' : 'idle'} hasOlder={hasMore} onLoadOlder={loadMore} />

For an AI backend, let useChat keep the state and stream the reply:

const chat = useChat({ adapter: async ({ messages, signal }) => streamText(await fetch(url, { method: 'POST', body: JSON.stringify({ messages }), signal })) });
<Chat {...chat} />
react-native-gifted-chatPatine
messages (newest first)messages (oldest first)
message._id, message.text, message.createdAt (Date)id, text (Markdown), createdAt (epoch ms)
user + message.user._id to tell mine from theirsrole: 'user' | 'assistant'
onSend(messages[])onSend(text, attachments)
GiftedChat.append / prependSpread the array, or let useChat do it
isTypingstatus="streaming" (a caret until the reply starts)
loadEarlier, onLoadEarlier, isLoadingEarlierhasOlder, onLoadOlder, loadingOlder, triggered by scrolling up
quickReplies on a messagesuggestions above the composer
message.imageattachments: [{ id, name, uri, mimeType }]
message.pending, message.sentstatus: 'sending' | 'done' | 'failed' (failed gets Retry)
renderBubble, renderMessagerenderMessage(message, defaultRender)
renderActionsonAttach
parsePatterns, react-native-parsed-textMarkdown, with links
bottomOffsetkeyboardOffset
renderAvatar, renderUsername, renderDayNot built in: wrap defaultRender() in renderMessage