> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-rn-guide-message-privately.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Users With Messages

> Users With Messages — CometChat documentation.

## Overview

The UsersWithMessages is a [Composite Component](/ui-kit/react-native/v4/components-overview#components) encompassing components such as [Users](/ui-kit/react-native/v4/users) and [Messages](/ui-kit/react-native/v4/messages). Each of these component contributes to the functionality and structure of the overall UsersWithMessages component.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/FGBCGWXGo5d9bVxR/images/c05a9bff-users_with_messages_overview_cometchat_screens-601ca0410b60eb8b7f02bf3f8a0bdf99.png?fit=max&auto=format&n=FGBCGWXGo5d9bVxR&q=85&s=1911ed55fa8ef668f23b2bff28515b7e" alt="Image" width="4498" height="3120" data-path="images/c05a9bff-users_with_messages_overview_cometchat_screens-601ca0410b60eb8b7f02bf3f8a0bdf99.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/7emVxEQ5MCxvzC60/images/188e8340-users_with_messages_overview_cometchat_screens-ef5775fd743e8d1f052211f0b2e13665.png?fit=max&auto=format&n=7emVxEQ5MCxvzC60&q=85&s=167caeec685b67e951710ca2e3e7732d" alt="Image" width="4498" height="3120" data-path="images/188e8340-users_with_messages_overview_cometchat_screens-ef5775fd743e8d1f052211f0b2e13665.png" />
  </Tab>
</Tabs>

| Components                                   | Description                                                                                                                     |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| [Users](/ui-kit/react-native/v4/users)       | The `Users` component is designed to display a list of `Users`.                                                                 |
| [Messages](/ui-kit/react-native/v4/messages) | The `Messages` component is designed to manage the messaging interaction for either individual `User` or `Group` conversations. |

## Usage

### Integration

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChatUsersWithMessages } from "@cometchat/chat-uikit-react-native";

    return <CometChatUsersWithMessages />;
    ```
  </Tab>
</Tabs>

***

### Actions

[Actions](/ui-kit/react-native/v4/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

##### 1. onError

This action doesn't change the behavior of the component but rather listens for any errors that occur in the UserWithMessages component.

The sub components - [Users](/ui-kit/react-native/v4/users#actions) and [Messages](/ui-kit/react-native/v4/messages).

The Action of the components can be overridden through the use of the [Configurations](#configurations) object of its components. Here is an example code snippet.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import { CometChatUsersWithMessages } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const onErrorHandler = (error: CometChat.CometChatException) => {
        //code
      };

      return (
        <CometChatUsersWithMessages
          onError={onErrorHandler}
        ></CometChatUsersWithMessages>
      );
    }
    ```
  </Tab>
</Tabs>

The UsersWithMessages component overrides several actions from its components to reach its default behavior. The list of actions overridden by UsersWithMessages includes:

* [onItemPress](/ui-kit/react-native/v4/users#2-onitempress) : By overriding the `onItemPress` of the Users Component, UsersWithMessages achieves navigation from [Users](/ui-kit/react-native/v4/users) to [Messages](/ui-kit/react-native/v4/messages) component.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/PaxBG9I1yMoeQmt2/images/3bb5ed0f-users_with_messages_item_press_cometchat_screens-3a3e9086521d01319761e116c6be6758.png?fit=max&auto=format&n=PaxBG9I1yMoeQmt2&q=85&s=26a53293c5a7a31bedcff1d5e287bc41" alt="Image" width="4498" height="3120" data-path="images/3bb5ed0f-users_with_messages_item_press_cometchat_screens-3a3e9086521d01319761e116c6be6758.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/mq8rEbFfi0JjKmkM/images/622e4d74-users_with_messages_item_press_cometchat_screens-db046627c1b3abbb9c266acb9f2e8b73.png?fit=max&auto=format&n=mq8rEbFfi0JjKmkM&q=85&s=25b2934e95089f8bfca646b6e49ea472" alt="Image" width="4498" height="3120" data-path="images/622e4d74-users_with_messages_item_press_cometchat_screens-db046627c1b3abbb9c266acb9f2e8b73.png" />
  </Tab>
</Tabs>

### Filters

**Filters** allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

While the UsersWithMessages component does not have filters, its components do, For more detail on individual filters of its component refer to [Users Filters](/ui-kit/react-native/v4/users#filters) and [Messages Filters](/ui-kit/react-native/v4/messages).

By utilizing the [Configurations](#configurations) object of its components, you can apply filters.

In the following **example**, we're filtering Users to only show `Friends`

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatUsersWithMessages,
      UsersConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const usersRequestBuilder = new CometChat.UsersRequestBuilder()
        .setLimit(5)
        .friendsOnly(true);

      const usersConfiguration: UsersConfigurationInterface = {
        usersRequestBuilder: usersRequestBuilder,
      };

      return (
        <CometChatUsersWithMessages
          usersConfiguration={usersConfiguration}
        ></CometChatUsersWithMessages>
      );
    }
    ```
  </Tab>
</Tabs>

***

### Events

[Events](/ui-kit/react-native/v4/components-overview#events) are emitted by a `Component`. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

The UsersWithMessages component and its components do not directly generate any events.

***

## Customization

To fit your app's design requirements, you have the ability to customize the appearance of the UsersWithMessages component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

### Style

Using **Style** you can **customize** the look and feel of the component in your app, These parameters typically control elements such as the **color**, **size**, **shape**, and **fonts** used within the component. UsersWithMessages component doesn't have its own style parameters. But you can customize its component styles. For more details on individual component styles, you can refer [User Styles](/ui-kit/react-native/v4/users#style) and [Messages Styles](/ui-kit/react-native/v4/messages#style). Styles can be applied to SubComponents using their respective [configurations](#configurations).

**Example**

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatUsersWithMessages,
      CometChatListStylesInterface,
      UsersConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const usersStyle: CometChatListStylesInterface = {
        background: "#ddd7f7",
        titleColor: "#6851D6",
      };

      const usersConfiguration: UsersConfigurationInterface = {
        usersStyle: usersStyle,
      };

      return (
        <CometChatUsersWithMessages
          usersConfiguration={usersConfiguration}
        ></CometChatUsersWithMessages>
      );
    }
    ```
  </Tab>
</Tabs>

### Functionality

These are a set of **small functional customizations** that allow you to **fine-tune** the overall experience of the component. With these, you can **change text**, set **custom icons**, and toggle the **visibility** of UI elements.

##### User Prop

You can pass a [User](/sdk/react-native/user-management) object as prop to the UsersWithMessages component. This will automatically direct you to the [Messages](/ui-kit/react-native/v4/messages) component for the specified `User`.

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import { CometChatUsersWithMessages } from "@cometchat/chat-uikit-react-native";

    const [user, setUser] = useState<CometChat.User | undefined>(undefined);

    const getUser = async () => {
      const user = await CometChat.getUser("uid");
      setUser(user);
    };

    useEffect(() => {
      getUser();
    }, []);

    return <CometChatUsersWithMessages user={user} />;
    ```
  </Tab>
</Tabs>

***

##### Components

Nearly all functionality customizations available for a Component are also available for the composite component. Using [Configuration](#configurations), you can modify the properties of its components to suit your needs.

You can find the list of all Functionality customization of individual components in [Users](/ui-kit/react-native/v4/users#functionality) and [Messages](/ui-kit/react-native/v4/messages#functionality)

**Example**

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatUsersWithMessages,
      UsersConfigurationInterface,
      MessagesConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    const [user, setUser] = useState<CometChat.User | undefined>(undefined);

    const getUser = async () => {
      const user = await CometChat.getUser("uid");
      setUser(user);
    };

    useEffect(() => {
      getUser();
    }, []);

    const usersConfiguration: UsersConfigurationInterface = {
      hideSearch: true,
      hideSeparator: true,
    };

    const messagesConfiguration: MessagesConfigurationInterface = {
      disableTyping: false,
      hideMessageComposer: false,
    };

    return (
      <CometChatUsersWithMessages
        usersConfiguration={usersConfiguration}
        messagesConfigurations={messagesConfiguration}
      />
    );
    ```
  </Tab>
</Tabs>

***

### Advanced

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your own views, layouts, and UI elements and then incorporate those into the component.

By utilizing the [Configuration](#configurations) object of each component, you can apply advanced-level customizations to the UsersWithMessages.

**Example**

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import {
      CometChatUsersWithMessages,
      UsersConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    const errorViewStyle: StyleProp<ViewStyle> = {
      flex: 1,
      alignItems: "center",
      justifyContent: "center",
      padding: 10,
      borderColor: "black",
      borderWidth: 1,
      backgroundColor: "#E8EAE9",
    };

    const getErrorStateView = () => {
      return (
        <View style={errorViewStyle}>
          <Text></Text>
        </View>
      );
    };

    const usersConfiguration: UsersConfigurationInterface = {
      ErrorStateView: getErrorStateView,
    };

    return <CometChatUsersWithMessages usersConfiguration={usersConfiguration} />;
    ```
  </Tab>
</Tabs>

***

To find all the details on individual Component advance customization you can refer, [Users Advanced](/ui-kit/react-native/v4/users#advanced) and [Messages Advanced](/ui-kit/react-native/v4/messages#advanced).

UsersWithMessages uses advanced-level customization of both Users & Messages components to achieve its default behavior.

1. UsersWithMessages utilizes the [AppBarOptions](/ui-kit/react-native/v4/messages#auxilaryappbaroptions) of the `Messages` subcomponent to navigate from [Messages](/ui-kit/react-native/v4/messages) to [Details](/ui-kit/react-native/v4/user-details)

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/ugckbRl5Q-H7t8X2/images/e237bdd7-users_with_messages_details_cometchat_screens-786f9e16636be5177545f9d5304c1f66.png?fit=max&auto=format&n=ugckbRl5Q-H7t8X2&q=85&s=386a53f15e47d4826af28680144e8609" alt="Image" width="4498" height="3136" data-path="images/e237bdd7-users_with_messages_details_cometchat_screens-786f9e16636be5177545f9d5304c1f66.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/OOBJyP9hM0C-rAe_/images/dca85e33-users_with_messages_details_cometchat_screens-4032e3cea9cfacb43dcaaf86807d04de.png?fit=max&auto=format&n=OOBJyP9hM0C-rAe_&q=85&s=f1b15f4b5935d11484a709b77ed49540" alt="Image" width="4498" height="3120" data-path="images/dca85e33-users_with_messages_details_cometchat_screens-4032e3cea9cfacb43dcaaf86807d04de.png" />
  </Tab>
</Tabs>

<Warning>
  When you override `AppBarOptions`, the default behavior of UsersWithMessages will also be overridden.
</Warning>

## Configurations

[Configurations](/ui-kit/react-native/v4/components-overview#configurations) offer the ability to customize the properties of each component within a Composite Component.

UsersWithMessages has `Users` and `Messages` component. Hence, each of these components will have its individual \`Configuration\`\`.

* `Configurations` expose properties that are available in its individual components.

#### Users

You can customize the properties of the Users component by making use of the usersConfiguration. You can accomplish this by employing the `usersConfiguration` props as demonstrated below:

<Tabs>
  <Tab title="App.tsx">
    ```tsx theme={null}
    import {
      CometChatUsersWithMessages,
      UsersConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    const usersConfiguration: UsersConfigurationInterface = {
      //override properties
    };

    return <CometChatUsersWithMessages usersConfiguration={usersConfiguration} />;
    ```
  </Tab>
</Tabs>

All exposed properties of `UsersConfiguration` can be found under [Users](/ui-kit/react-native/v4/users#functionality).

**Example**

Let's say you want to change the style of the Users subcomponent and, in addition, you only want to display friends in the users list.

You can modify the style using the `usersStyle` property and filter the list with the `usersRequestBuilder` property.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/Xgdtn9VZPDi47bm-/images/24963df4-uwm_users_config_cometchat_screens-040db7419adb50121ee589a056c82ed9.png?fit=max&auto=format&n=Xgdtn9VZPDi47bm-&q=85&s=3c8c4a49307a51ce2a3f4b856490996d" alt="Image" width="4498" height="3120" data-path="images/24963df4-uwm_users_config_cometchat_screens-040db7419adb50121ee589a056c82ed9.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/Gp90C5sdVtuRR4t7/images/7e8a36c6-uwm_users_config_cometchat_screens-d700714ca27be3fd1e7398f44a3aa32e.png?fit=max&auto=format&n=Gp90C5sdVtuRR4t7&q=85&s=c2b136e052df4f1e74a78bd2235b9e3c" alt="Image" width="4498" height="3120" data-path="images/7e8a36c6-uwm_users_config_cometchat_screens-d700714ca27be3fd1e7398f44a3aa32e.png" />
  </Tab>
</Tabs>

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatUsersWithMessages,
      CometChatListStylesInterface,
      UsersConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const customRequestBuilder: CometChat.UsersRequestBuilder =
        new CometChat.UsersRequestBuilder().setLimit(5).friendsOnly(true);

      const customUserStyle: CometChatListStylesInterface = {
        background: "#ddd7f7",
        titleColor: "#6851D6",
      };

      const usersConfiguration: UsersConfigurationInterface = {
        usersStyle: customUserStyle,
        usersRequestBuilder: customRequestBuilder,
      };

      return (
        <CometChatUsersWithMessages
          usersConfiguration={usersConfiguration}
        ></CometChatUsersWithMessages>
      );
    }
    ```
  </Tab>
</Tabs>

***

#### Messages

You can customize the properties of the Messages component by making use of the messagesConfiguration. You can accomplish this by employing the `messagesConfiguration` props as demonstrated below:

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import {
      CometChatUsersWithMessages,
      MessagesConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    const messagesConfiguration: MessagesConfigurationInterface = {
      //override properties
    };
    return (
      <CometChatUsersWithMessages messagesConfigurations={messagesConfiguration} />
    );
    ```
  </Tab>
</Tabs>

All exposed properties of `MessagesConfiguration` can be found under [Messages](/ui-kit/react-native/v4/messages#configuration).

**Example**

Let's say you want to change the style of the Messages subcomponent and, in addition, you only want to hide message header.

You can modify the style using the `messagesStyle` property and hide the message header with the `hideMessageHeader` property.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/19qJLi95IaEk2j9s/images/fe6cb033-uwm_messages_config_cometchat_screens-46013af3a560b75931d12ae14d238510.png?fit=max&auto=format&n=19qJLi95IaEk2j9s&q=85&s=426d7c736b6bbecc53b18f9ded1f218c" alt="Image" width="4498" height="3120" data-path="images/fe6cb033-uwm_messages_config_cometchat_screens-46013af3a560b75931d12ae14d238510.png" />
  </Tab>

  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/7emVxEQ5MCxvzC60/images/1cedce96-uwm_messages_config_cometchat_screens-b276d6cd8af662fa6b6e5c5dda2753fd.png?fit=max&auto=format&n=7emVxEQ5MCxvzC60&q=85&s=b630768123d45e837d01f63e4aea2841" alt="Image" width="4498" height="3120" data-path="images/1cedce96-uwm_messages_config_cometchat_screens-b276d6cd8af662fa6b6e5c5dda2753fd.png" />
  </Tab>
</Tabs>

<Tabs>
  <Tab title="TypeScript">
    ```ts theme={null}
    import {
      CometChatUsersWithMessages,
      MessagesConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    const messagesConfiguration: MessagesConfigurationInterface = {
      hideMessageHeader: true,
      hideMessageComposer: true,
    };

    return (
      <CometChatUsersWithMessages messagesConfigurations={messagesConfiguration} />
    );
    ```
  </Tab>
</Tabs>

***
