useChats hook

the useChats hook is used to interface with chats.

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.

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

chats

the list of chats returned. this is automatically updated whenever a new chat is started by the current user or someone else.

loading

boolean

Shows the state of querying the chats, used to update your UI to show loading state

error

object

an error object that is defined if an error occured while trying to query the chats.

paginate

function

function called to get the next 25 chats, the chats are automatically added to the begining of the chats array.

paginateLoading

boolean

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

Last updated