Skip to main content

Chat

The Chat component is a React Context provider that wraps the entire Web3MQ Chat application. All chat Components within the @web3mq/react-components library must be nested as children of Chat to maintain proper functionality.

Basic Usage​

The Chat component does not inject any UI, so its implementation is fairly simple. Once an instance of the Chat client has been created, you pass the client object as a prop to add it to the ChatContext.

containerId​

Used to wrap a container around a Chat component.You need to pass the container's unique id selector as a prop to the Chat component, and all child components in chat will adapt to that container

tip

The container style must set position is a property other than static

<div id='box' style={{position: 'relative'}}>
<Chat containerId='box' client={client}>
<ChannelList />
<Channel>
<MessageList />
<MessageInput />
</Channel>
</Chat>
</div>

useChatContext​

Any child of the Chat component has access to the ChatContext. Each React Context in the component library can be accessed with one of our custom hooks, which must be imported individually.

const { client } = useChatContext();

Api​

Chat​

The properties of the Chat are described as follows:

PropertyDescriptionTypeDefaultrequired
appTypeset viewport type of @web3mq/react-componentsAppTypeEnumAppTypeEnum["pc"]false
classNameset your custom classNamestring""false
clientchat Client InstanceClient-true
containerIdSet a unique id selector for the container wrapping chatstring""false
styleset your custom styleReact.CSSPropertiesnullfalse
logoutset your exit methodFunction-true

useChatContext data​

PropertyDescriptionTypeDefaultrequired
appTypeset viewport type of @web3mq/react-componentsAppTypeEnumAppTypeEnum["pc"]-
clientClient InstanceClient--
containerIdid selector for the node that wraps the Chat componentstring""-
activeNotificationcurrent Active Notifications in notification listNotifyResponsenull-
showListTypeViewTabs type in DashBoard componentstring"room"-
loginUserInfocurrent user InfoCommonUserInfoTypenull-
getUserInfoget target user information1.didValue: string 2.didType: didType 3.bindDid: boolean--
logoutset your exit methodFunction--
setShowListTypeViewUpdate showListTypeViewReact.Dispatch--
setActiveNotificationUpdate current notification as active in notification listReact.Dispatch--

AppTypeEnum​

enum AppTypeEnum {
'pc' = 'pc',
'h5' = 'h5',
'mobile' = 'mobile',
}

CommonUserInfoType​

PropertyDescriptionTypeDefaultrequired
addresswallet addressstring-true
defaultUserNamedefault usernamestring-true
defaultUserAvatardefault avatar urlstring-true
didValuesdid valueDidValueType[]-true
didValueMapdid value of mapRecord<WEB3_MQ_DID_TYPE, string>-true
permissionsuser permissionsUserPermissionsType-true
statsfollow stats info{total_followers:number,total_following:number}-true
useriduserid of userstring-true
wallet_addresswallet addressstring-true
wallet_typewallet typestring-true

DidValueType​

PropertyDescriptionTypeDefaultrequired
did_typedid typeWEB3_MQ_DID_TYPE-true
did_valueaddress corresponding to didTypestring-true
detaildetailany-true
provider_idprovider idstring-true

WEB3_MQ_DID_TYPE​

enum WEB3_MQ_DID_TYPE {
PHONE = 'phone',
EMAIL = 'email',
LENS = 'lens.xyz',
DOTBIT = 'dotbit',
ENS = 'ens',
}