UI Components
UI Components are building blocks of the UI Kit. UI Components are a set of custom classes specially designed to build a rich chat app. There are different UI Components available in the UI Kit Library.
CometChatUI
CometChatUI is an option to launch a fully functional chat application using the UI Kit. In CometChatUI all the UI Components are interlinked and work together to launch a fully functional chat on your application.

- Javascript
import React from 'react';
import {View, Text} from 'react-native';
import {CometChatUI} from '../cometchat-pro-react-native-ui-kit';
export default function CometChatUIView() {
return (
<View style={{flex: 1}}>
<CometChatUI />
</View>
);
}
CometChatUserListWithMessages
The CometChatUserListWithMessages
is a component with a list of users. The component has all the necessary listeners and methods required to display the user's list and shows the set of the messages/chats of the selected user

- Javascript
import { CometChatUserListWithMessages } from '../cometchat-pro-react-native-ui-kit';
function StackNavigator(props) {
const Stack = createStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator
headerMode="none"
initialRouteName={"UserListWithMessages"}>
<Stack.Screen name="UserListWithMessages" component={CometChatUserListWithMessages} />
</Stack.Navigator>
</NavigationContainer>
);
}
If you want to use this as a child component, then use the below code.
- Javascript
import React from 'react';
import {View} from 'react-native';
import {CometChatUserListWithMessages} from '../cometchat-pro-react-native-ui-kit';
export default function CometChatUserListWithMessagesView({navigation}) {
return (
<View style={{flex: 1}}>
<CometChatUserListWithMessages navigation={navigation}/>
</View>
);
}
CometChatGroupListWithMessages
The CometChatGroupWithMessages
is a component with a list of groups. The component has all the necessary listeners and methods required to display the group's list and shows the set of the messages/chats of the selected group

- Javascript
import { CometChatGroupListWithMessages } from '../cometchat-pro-react-native-ui-kit';
function StackNavigator(props) {
const Stack = createStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator
headerMode="none"
initialRouteName={"GroupListWithMessages"}>
<Stack.Screen name="GroupListWithMessages" component={CometChatGroupListWithMessages} />
</Stack.Navigator>
</NavigationContainer>
);
}
If you want to use this as a child component, then use the below code.
- Javascript
import React from 'react';
import {View, Text} from 'react-native';
import {CometChatGroupListWithMessages} from '../cometchat-pro-react-native-ui-kit';
export default function CometChatGroupListWithMessagesView({navigation}) {
return (
<View style={{flex: 1}}>
<CometChatGroupListWithMessages navigation={navigation} />
</View>
);
}
CometChatMessages
The CometChatMessages
is a component with a list of messages/chats and shows the message component header and message composer.

- Javascript
import React, {useEffect, useState} from 'react';
import {View} from 'react-native';
import {CometChat} from '@cometchat-pro/react-native-chat';
import {CometChatMessages} from '../cometchat-pro-react-native-ui-kit';
export default function CometChatMessagesView({navigation}) {
const [localUser, setLocalUser] = useState(null);
useEffect(() => {
var user = CometChat.getLoggedinUser().then(
(user) => {
console.log('user details:', {user});
setLocalUser(user);
},
(error) => {
console.log('error getting details:', {error});
},
);
}, []);
return (
<View style={{flex: 1}}>
{localUser ? (
<CometChatMessages
type={'user'}
item={userOrGroupObject}//The object will be of user or group depending on type
loggedInUser={localUser}
actionGenerated={(actionType) => {
console.log(actionType);
}}
/>
) : null}
</View>
);
}
Parameter | Description | Type |
---|---|---|
type | Value should be string. defines the type of chat. Its value can be user or "group". | Optional |
item | Value should be Object. The object will be of user or group depending on type. This is an example object for user { hasBlockedMe: false, blockedByMe: false, uid: 'cometchat-uid-3', name: 'Nancy Grace', avatar: 'https://data-us.cometchat.io/assets/images/avatars/cometchat-uid-3.webp', lastActiveAt: 1614597611, role: 'default', status: 'offline', } | Required |
loggedInUser | Value should be Object. This props takes the details of current logged in user, | Required |
actionGenerated | Value should be function. Tis is a callback function called when user perform certain actions on screen. List of actionType are as follow: 1)groupDeleted: This is called when user deletes the group. 2) membersUpdated: This is called when members of group are updated. 3)messageRead : This is called when last message is read. 4)messageComposed: is called when new message is composed. 5)messageDeleted: This is called when message is been deleted. 6)viewActualImage: This is called when user clicks on Image. 7)menuClicked: This is called when the menu in header has been clicked. 8)threadMessageComposed: This is called when new thread message has been composed 9)blockUser: This is called when user is blocked 10)updateThreadMessage: This is called when thread message is updated. 11)messageEdited: This is called when a message is edited. 12)groupUpdated: This is called when a group property has been updated. | Required |
CometChatConversationListWithMessages
The CometChatConversationListWithMessages
is a component with a list of recent conversations. The component has all the necessary listeners and methods required to display the recent conversation list and shows the set of the messages/chats of the selected recent conversation

- Javascript
import { CometChatConversationListWithMessages } from '../cometchat-pro-react-native-ui-kit';
function StackNavigator(props) {
const Stack = createStackNavigator();
return (
<NavigationContainer>
<Stack.Navigator
headerMode="none"
initialRouteName={"ConversationListWithMessages"}>
<Stack.Screen name="ConversationListWithMessages" component={CometChatConversationListWithMessages} />
</Stack.Navigator>
</NavigationContainer>
);
}
If you want to use this as a child component, then use the below code.
- Javascript
import React from 'react';
import {View, Text} from 'react-native';
import {CometChatConversationListWithMessages} from '../cometchat-pro-react-native-ui-kit';
export default function CometChatConversationListWithMessagesView({
navigation,
}) {
return (
<View style={{flex: 1}}>
<CometChatConversationListWithMessages navigation={navigation} />
</View>
);
}