# Migrate from react-native-gifted-chat

> Switch from react-native-gifted-chat to Patine: Chat and useChat for AI assistants and messaging, with streaming Markdown replies, reasoning, tool calls, stop, retry, older history on scroll-up and a keyboard-aware composer. React Native core only, no keyboard-controller or reanimated.

# 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`](../../blocks/ai-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`](../../components/chat).

```diff
- 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:

```tsx
const chat = useChat({ adapter: async ({ messages, signal }) => streamText(await fetch(url, { method: 'POST', body: JSON.stringify({ messages }), signal })) });
<Chat {...chat} />
```

| react-native-gifted-chat | Patine |
| --- | --- |
| `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 theirs | `role: 'user' \| 'assistant'` |
| `onSend(messages[])` | `onSend(text, attachments)` |
| `GiftedChat.append` / `prepend` | Spread the array, or let `useChat` do it |
| `isTyping` | `status="streaming"` (a caret until the reply starts) |
| `loadEarlier`, `onLoadEarlier`, `isLoadingEarlier` | `hasOlder`, `onLoadOlder`, `loadingOlder`, triggered by scrolling up |
| `quickReplies` on a message | `suggestions` above the composer |
| `message.image` | `attachments: [{ id, name, uri, mimeType }]` |
| `message.pending`, `message.sent` | `status: 'sending' \| 'done' \| 'failed'` (failed gets Retry) |
| `renderBubble`, `renderMessage` | `renderMessage(message, defaultRender)` |
| `renderActions` | `onAttach` |
| `parsePatterns`, `react-native-parsed-text` | Markdown, with links |
| `bottomOffset` | `keyboardOffset` |
| `renderAvatar`, `renderUsername`, `renderDay` | Not built in: wrap `defaultRender()` in `renderMessage` |
