如何解决如何在sendbird-uikit包的onChannelSelect道具中使用setState方法设置条件以设置频道网址?
每当呈现组件时,都会调用onChannelSelect 函数,从而重置 channelUrl 变量。因为当我们单击任何频道时,该频道网址不会更改。每次第一个频道的网址是从频道列表中设置的。那么我该如何使用setState方法设置频道网址?
import { ChannelList,SendBirdProvider,Channel } from "sendbird-uikit";
setChannelUrl = (channel) => {
console.log("channel",channel.url)
this.setState({ channelUrl: channel.url })
}
<div className="container cart">
<SendBirdProvider appId={global.chat.sendbirdAppId}
userId={profile.sendbird_id} >
<div className="card card-aspenku">
<div className="row">
<div className="col-md-4" style={{ height: '400px' }} >
<ChannelList
onChannelSelect={(channel) => {
if (this.state.channelUrl === "" ||
this.state.channelUrl !== channel.url)
{
console.log("channel")
this.setChannelUrl(channel)
}
else {
console.log("no channel")
}
}}
queries={{
channelListQuery: {
includeEmpty: true,},applicationUserListQuery: {
limit: 30,userIdsFilter: [profile.sendbird_id],}
}}
/>
</div>
<div className="col-md-8" style={{ height: '400px' }}>
{this.state.channelUrl && <Channel
channelUrl={this.state.channelUrl}
queries={{
messageListParams: {
senderUserIds: [profile.sendbird_id],prevResultSize: 10,includeParentMessageText: true,includeReaction: true,}
}}
/>}
</div>
</div>
</div>
</SendBirdProvider>
</div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。