我在Reaction应用程序中初始化CometChat时遇到了一个问题.
我得到的错误是:
Error: Cannot find name 'setCometChat'. Did you mean 'CometChat'?
'CometChat' is declared here.
我给初始化打了useEffect
分:
useEffect(() => {
initCometChat();
// ...
}, []);
下面是initCometChat
的函数:
const initCometChat = async () => {
const { CometChat } = await import('@cometchat-pro/cordova-ionic-chat');
const appID = `${process.env.REACT_APP_COMETCHAT_APP_ID}`;
const region = `${process.env.REACT_APP_COMETCHAT_REGION}`;
const appSetting = new CometChat.AppSettingsBuilder().subscribePresenceForAllUsers().setRegion(region).build();
CometChat.init(appID, appSetting).then(
() => {
console.log('CometChat was initialized successfully');
setCometChat(() => CometChat);
},
error => {
}
);
};
我try 按如下方式使用传入的setter函数:
setCometChat(CometChat);
但这并不管用.