尝试实现GetStream LiveStream聊天,但是尝试在页面加载时尝试验证聊天用户时遇到此错误...。此错误是什么意思?我在文档中找不到任何内容。
当我先将用户登录到另一个页面然后导航到聊天页面时,不会发生该错误。 EG:
User goes to landing page > logs in > back to landing page >goes to chat ==> no crash
User is already authenticated from a previous session > goes to chat page ==> crash
聊天组件
const ChatBox = ({auth}) => {
const chatClient = new StreamChat(`48t6pc8z54ef`);
if (auth.isAuthenticated) {
const userToken = auth.user.chatToken;
chatClient.setUser(
{
id: auth.user._id,
name: auth.user.name,
image: auth.user.chatImage
},
userToken,
)
} else {
chatClient.setAnonymousUser()
}
const channel = chatClient.channel('livestream', 'CreatorStream', {
image: 'image',
name: 'CreatorStream Chat',
})
return (
<Chat client={chatClient} theme={'livestream dark'}>
<Channel channel={channel} Message={MessageLivestream}>
<div className="str-chat__main-panel">
<Window hideOnThread>
<ChannelHeader live/>
<MessageList/>
<MessageInput Input={MessageInputSmall} focus/>
</Window>
<Thread fullWidth/>
</div>
</Channel>
</Chat>
)
}
const mapStateToProps = state => ({
auth: state.auth
})
// export default ChatBox;
export default connect(mapStateToProps, {})(ChatBox)
聊天实施
<div className="chat-div">
{loading ? <Spinner/> : auth.user === null ?
<ChatBox/> : auth.user.chatToken ?
<ChatBox/> : <Spinner/>}
</div>