> ## 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.

# Groups With Messages

> Groups With Messages — CometChat documentation.

The GroupsWithMessages is a [Composite Component](/ui-kit/react-native/v4/components-overview#composite-components) encompassing components such as [Groups](/ui-kit/react-native/v4/groups) and [Messages](/ui-kit/react-native/v4/messages). Both of these component contributes to the functionality and structure of the overall GroupsWithMessages component.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/xIG5VBdyNJ5cYSqE/images/d3c2d412-groups_with_messages_overview_cometchat_screens-d343d2cb8b7b9d0a911096ab7b128c8d.png?fit=max&auto=format&n=xIG5VBdyNJ5cYSqE&q=85&s=16ffcda73b32c9e52e7885aac09fb86a" alt="Image" width="4498" height="3120" data-path="images/d3c2d412-groups_with_messages_overview_cometchat_screens-d343d2cb8b7b9d0a911096ab7b128c8d.png" />
  </Tab>
</Tabs>

The GroupsWithMessages component is composed of the following BaseComponents:

| Components                                   | Description                                                                                                                     |
| -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
| [Groups](/ui-kit/react-native/v4/groups)     | The `Groups` component is designed to display a list of `Groups`. This essentially represents the recent conversation history.  |
| [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

The following code snippet illustrates how you can directly incorporate the Groups component into your `App.tsx` file.

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

    function App(): React.JSX.Element {
      return <CometChatGroupsWithMessages />;
    }
    ```
  </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 User component.

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

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

      return <CometChatGroupsWithMessages onError={onErrorHandler} />;
    }
    ```
  </Tab>
</Tabs>

The child components - [Groups](/ui-kit/react-native/v4/groups) and [Messages](/ui-kit/react-native/v4/messages) - both have their own set of actions. The Actions of these components can be overridden through the use of the [Configurations](/ui-kit/react-native/v4/groups-with-messages#configurations) object. Here is an example code snippet.

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

    function App(): React.JSX.Element {
      const groupsRequestBuilder = new CometChat.GroupsRequestBuilder()
        .setLimit(3)
        .joinedOnly(true);
      const groupsConfiguration: GroupsConfigurationInterface = {
        onItemLongPress(item) {
          //code
        },
        groupsRequestBuilder: groupsRequestBuilder,
        onItemPress(item) {
          //code
        },
      };

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

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

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

* [onItemPress](/ui-kit/react-native/v4/groups#2-onitempress) : By overriding the OnItemClick of the [Groups](/ui-kit/react-native/v4/groups) Component, GroupsWithMessages achieves navigation from [Groups](/ui-kit/react-native/v4/groups) 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/mNTojjz_O28of40c/images/f3af235a-groups_with_messages_on_item_press_cometchat_screens-db164b5812b022a64217e382cacd7b3d.png?fit=max&auto=format&n=mNTojjz_O28of40c&q=85&s=376925dc0ff045d720625289e148eb26" alt="Image" width="4498" height="3120" data-path="images/f3af235a-groups_with_messages_on_item_press_cometchat_screens-db164b5812b022a64217e382cacd7b3d.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 GroupsWithMessages component does not have filters, its components do, For more detail on individual filters of its component refer to [Groups Filters](/ui-kit/react-native/v4/groups#filters) and [Messages Filters](/ui-kit/react-native/v4/messages#filters).

By utilizing the [Configurations](/ui-kit/react-native/v4/groups-with-messages#configurations) object of its components, you can apply filters.

In the following example, we are applying a filter to the Group List based on only joined groups and setting the limit to 3 using the groupsRequestBuilder.

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

    function App(): React.JSX.Element {
      const groupsRequestBuilder = new CometChat.GroupsRequestBuilder()
        .setLimit(3)
        .joinedOnly(true);

      const groupsConfiguration: GroupsConfigurationInterface = {
        groupsRequestBuilder: groupsRequestBuilder,
      };

      return (
        <CometChatGroupsWithMessages groupsConfiguration={groupsConfiguration} />
      );
    }
    ```
  </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 GroupsWithMessages does not produce any events but its component does.

## Customization

To fit your app's design requirements, you can customize the appearance of the `GroupsWithMessages` 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.

GroupsWithMessages does not have a style property but you can customize its sub-component styles. For more details on individual component styles, you can refer [Groups Styles](/ui-kit/react-native/v4/groups#style) and [Messages Styles](/ui-kit/react-native/v4/messages#style).

Styles can be applied to SubComponents using their respective configurations.

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

    function App(): React.JSX.Element {
      const groupsStyle: GroupsStyleInterface = {
        titleColor: "red",
        backgroundColor: "#d2cafa",
      };

      const groupsConfiguration: GroupsConfigurationInterface = {
        groupsStyle: groupsStyle,
      };

      const messageStyle: MessageStyleInterface = {
        backgroundColor: "#6851D6",
      };

      const messagesConfiguration: MessagesConfigurationInterface = {
        messagesStyle: messageStyle,
      };

      return (
        <CometChatGroupsWithMessages
          groupsConfiguration={groupsConfiguration}
          messagesConfiguration={messagesConfiguration}
        />
      );
    }
    ```
  </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.

you can utilize the group method with a [Group](/ui-kit/react-native/v4/groups) object as input to the GroupsWithMessages component. This will automatically direct you to the [Messages](/ui-kit/react-native/v4/messages) component for the specified Group.

##### 1. Group

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

    function App(): React.JSX.Element {
      const [group, setGroup] = useState<CometChat.Group | undefined>(undefined);

      const getGroup = async () => {
        const group = await CometChat.getGroup("guid");
        setGroup(group);
      };

      useEffect(() => {
        //login
        getGroup();
      });

      return (
        <>
          {group && (
            <CometChatGroupsWithMessages
              group={group}
            ></CometChatGroupsWithMessages>
          )}
        </>
      );
    }
    ```
  </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 [Groups](/ui-kit/react-native/v4/groups#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 {
      CometChatGroupsWithMessages,
      GroupsConfigurationInterface,
      MessagesConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const groupsRequestBuilder = new CometChat.GroupsRequestBuilder()
        .setLimit(10)
        .joinedOnly(true);

      const groupsConfiguration: GroupsConfigurationInterface = {
        groupsRequestBuilder: groupsRequestBuilder,
      };

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

      return (
        <CometChatGroupsWithMessages
          groupsConfiguration={groupsConfiguration}
          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 GroupsWithMessages.

**Example**

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

    function App(): React.JSX.Element {
      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>Error</Text>
          </View>
        );
      };

      const groupsConfiguration: GroupsConfigurationInterface = {
        ErrorStateView: getErrorStateView,
      };

      return (
        <CometChatGroupsWithMessages groupsConfiguration={groupsConfiguration} />
      );
    }
    ```
  </Tab>
</Tabs>

***

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

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

1. GroupsWithMessages utilizes the [onItemPress](/ui-kit/react-native/v4/groups#2-onitempress) property of the `Groups` subcomponent to navigate the group from [Groups](/ui-kit/react-native/v4/groups) to [Messages](/ui-kit/react-native/v4/messages)

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/mNTojjz_O28of40c/images/f3af235a-groups_with_messages_on_item_press_cometchat_screens-db164b5812b022a64217e382cacd7b3d.png?fit=max&auto=format&n=mNTojjz_O28of40c&q=85&s=376925dc0ff045d720625289e148eb26" alt="Image" width="4498" height="3120" data-path="images/f3af235a-groups_with_messages_on_item_press_cometchat_screens-db164b5812b022a64217e382cacd7b3d.png" />
  </Tab>
</Tabs>

2. GroupsWithMessages 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/group-details)

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/3EDM5JvI4mnAULac/images/74397466-groups_with_messages_details_cometchat_screens-2fc69a896a80f2b10ddb00bd2d1ecf46.png?fit=max&auto=format&n=3EDM5JvI4mnAULac&q=85&s=79816859641db21d0ff6fe11c439368c" alt="Image" width="4498" height="3120" data-path="images/74397466-groups_with_messages_details_cometchat_screens-2fc69a896a80f2b10ddb00bd2d1ecf46.png" />
  </Tab>
</Tabs>

<Warning>
  When you override `onItemPress` and `AppBarOptions`, the default behavior of GroupsWithMessages 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.

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

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

#### Groups

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

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

    function App(): React.JSX.Element {
      const groupsConfiguration: GroupsConfigurationInterface = {
        //override properties
      };

      return (
        <CometChatGroupsWithMessages groupsConfiguration={groupsConfiguration} />
      );
    }
    ```
  </Tab>
</Tabs>

All exposed properties of `GroupsConfiguration` can be found under [Groups](/ui-kit/react-native/v4/groups#functionality). 🛑 symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Groups subcomponent and, in addition, you only want to display the Group List based on only joined groups and setting the limit to 3.

You can modify the style using the `groupsStyle` property and filter the list with the `groupsRequestBuilder` property.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/XgQ9DxAoWn0btB5m/images/5bac2fc9-groups_with_messages_groups_style_cometchat_screens-c5238a5045433788b7ee0bde12e5bfad.png?fit=max&auto=format&n=XgQ9DxAoWn0btB5m&q=85&s=c0a122f8831d62f939258ed9a69fb1e1" alt="Image" width="4498" height="3120" data-path="images/5bac2fc9-groups_with_messages_groups_style_cometchat_screens-c5238a5045433788b7ee0bde12e5bfad.png" />
  </Tab>
</Tabs>

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

    function App(): React.JSX.Element {
      const groupsStyle: GroupsStyleInterface = {
        titleColor: "red",
        backgroundColor: "#d2cafa",
      };

      const groupsRequestBuilder = new CometChat.GroupsRequestBuilder()
        .setLimit(3)
        .joinedOnly(true);

      const groupsConfiguration: GroupsConfigurationInterface = {
        groupsRequestBuilder: groupsRequestBuilder,
        groupsStyle: groupsStyle,
      };

      return (
        <CometChatGroupsWithMessages groupsConfiguration={groupsConfiguration} />
      );
    }
    ```
  </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="App.tsx">
    ```tsx theme={null}
    import { CometChat } from "@cometchat/chat-sdk-react-native";
    import {
      CometChatGroupsWithMessages,
      MessagesConfigurationInterface,
    } from "@cometchat/chat-uikit-react-native";

    function App(): React.JSX.Element {
      const messagesConfiguration: MessagesConfigurationInterface = {
        //override properties
      };

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

All exposed properties of `MessagesConfiguration` can be found under [Messages](/ui-kit/react-native/v4/messages#functionality). 🛑 symbol are not accessible within the Configuration Object.

**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/Xgdtn9VZPDi47bm-/images/23958423-groups_with_messages_messages_cometchat_screens-f42de97e37e7cc7bf062c453584c07a9.png?fit=max&auto=format&n=Xgdtn9VZPDi47bm-&q=85&s=79d761e4f8aa97c94a91d1e91f4f9512" alt="Image" width="4498" height="3120" data-path="images/23958423-groups_with_messages_messages_cometchat_screens-f42de97e37e7cc7bf062c453584c07a9.png" />
  </Tab>
</Tabs>

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

    function App(): React.JSX.Element {
      const messageStyle: MessageStyleInterface = {
        //override style
      };

      const messagesConfiguration: MessagesConfigurationInterface = {
        hideMessageHeader: true,
        messagesStyle: messageStyle,
      };

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

***

#### Create Group

You can customize the properties of the Create Group component by making use of the CreateGroupConfiguration. You can accomplish this by employing the `createGroupConfiguration` props as demonstrated below:

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

    function App(): React.JSX.Element {
      const createGroupConfiguration: CreateGroupConfigurationInterface = {
        //override properites
      };

      return (
        <CometChatGroupsWithMessages
          createGroupConfiguration={createGroupConfiguration}
        />
      );
    }
    ```
  </Tab>
</Tabs>

All exposed properties of `CreateGroupConfiguration` can be found under [Create Group](/ui-kit/react-native/v4/create-group#functionality). 🛑 symbol are not accessible within the Configuration Object.

**Example**

Let's say you want to change the style of the Create Group subcomponent.

You can modify the style using the `createGroupStyle` property.

<Tabs>
  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-rn-guide-message-privately/PrOf0fpV33FkfOMB/images/10ea2f13-groups_with_messages_create_group_cometchat_screens-e38c2341cb1064c0bca7a824803f346c.png?fit=max&auto=format&n=PrOf0fpV33FkfOMB&q=85&s=4bf7bcacebfb6a5983e0137e27516ea3" alt="Image" width="4498" height="3120" data-path="images/10ea2f13-groups_with_messages_create_group_cometchat_screens-e38c2341cb1064c0bca7a824803f346c.png" />
  </Tab>
</Tabs>

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

    function App(): React.JSX.Element {
      const createGroupStyle: CreateGroupStyleInterface = {
        background: "#6851D6",
      };

      const createGroupConfiguration: CreateGroupConfigurationInterface = {
        createGroupStyle: createGroupStyle,
        onBack: () => {
          //code
        },
      };

      return (
        <CometChatGroupsWithMessages
          createGroupConfiguration={createGroupConfiguration}
        />
      );
    }
    ```
  </Tab>
</Tabs>

***
