npm i @cometchat-pro/chat
useEffect(()=>{
window.CometChat=require('@cometchat-pro/chat').CometChat
});
componentDidMount(){
}
import dynamic from "next/dynamic";
const CometChatNoSSR = dynamic(
() => import('./CometChatNoSSR'),
{ ssr: false }
);
import { Component } from "react";
import consts from './consts';
export default class CometChatNoSSR extends Component{
constructor(props){
super(props);
this.state={
user:undefined
}
componentDidMount(){
let appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(consts.region).build();
CometChat.init(consts.appId, appSetting).then(
() => {
var UID = "UID";
var apiKey = consts.apiKey;
CometChat.login(UID, apiKey).then(
user => {
this.setState({user})
},
error => {
console.log("Login failed with exception:", {
SDK
npm i @cometchat-pro/chat
useEffect(()=>{
window.CometChat=require('@cometchat-pro/chat').CometChat
});
componentDidMount(){
window.CometChat=require('@cometchat-pro/chat').CometChat
}
import dynamic from "next/dynamic";
const CometChatNoSSR = dynamic(
() => import('./CometChatNoSSR'),
{ ssr: false }
);
import { Component } from "react";
import consts from './consts';
export default class CometChatNoSSR extends Component{
constructor(props){
super(props);
this.state={
user:undefined
}
}
componentDidMount(){
let appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(consts.region).build();
CometChat.init(consts.appId, appSetting).then(
() => {
var UID = "UID";
var apiKey = consts.apiKey;
CometChat.login(UID, apiKey).then(
user => {
this.setState({user})
},
error => {
console.log("Login failed with exception:", {