# useChats hook

the `useChats` hook is used to interface with chats.

```javascript
import { useChats } from '@minchat/react';
```

### Get list of conversations

You can get a list of the conversations of the current user. conversations retrieved are paginated to 25 messages at a time. New conversations started by other users or messages sent to conversations that are on a different page are automatically added to the `chats` array.

```javascript
const { chats, loading, error, paginate, paginateLoading } = useChats()
```

<table><thead><tr><th width="223">Field</th><th width="130.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>chats</code></td><td><a href="../react-native-sdk/conversation-chat"><code>Chat[]</code></a></td><td>the list of chats returned. this is automatically updated whenever a new chat is started by the current user or someone else.</td></tr><tr><td><code>loading</code></td><td><code>boolean</code></td><td>Shows the state of querying the chats, used to update your UI to show loading state</td></tr><tr><td><code>error</code></td><td><code>object</code></td><td>an error object that is defined if an error occured while trying to query the chats.</td></tr><tr><td><code>paginate</code></td><td><code>function</code></td><td>function called to get the next 25 chats, the chats are automatically added to the begining of the chats array.</td></tr><tr><td><code>paginateLoading</code></td><td><code>boolean</code></td><td>Shows the state of a paginated query for chats, used to update your UI to show pagination state. is true when the paginate function is called and is false when chats are returned</td></tr></tbody></table>
