react-native - React Native - 有天赋的聊天消息问题
问题描述
我正在使用react-native-gifted-chat版本“^0.16.3”,但每次收到新消息时,它只会更新最后 2 条消息。我可以做些什么来更新新消息的完整聊天列表,这是正确的做法吗?
<View style={{
backgroundColor: 'white',
padding: 10,
width: "85%",
borderRadius: 5,
shadowColor: '#000',
shadowOffset: { width: 0, height: 0 },
shadowOpacity: 0.4,
shadowRadius: 1,
elevation: 5
}}>
{/* <Text color={'black'} bold size={'4.4%'} style={{ paddingLeft: 10 }} >Client wants to hire you</Text> */}
<Bubble
{...item}
allowFontScaling={false}
wrapperStyle={{
right: {
backgroundColor: Theme.darkSkyBlue,
width:'100%'
},
left: {
backgroundColor: Theme.white,
width:'100%'
}
}}
/>
{ !answered && type === "button" && (
<Row style={{width:'100%'}}>
<Btn style={{width:'48%'}} onPress={() => requestOpportunities(State.TrainerHire, requestId, _id)} yes>
<Btn.Text allowFontScaling = {false}>YES</Btn.Text>
</Btn>
<Btn style={{width:'48%'}} activeOpacity={0.3} onPress={() => requestOpportunities(State.TrainerAccept, requestId, _id)} packages>
<Btn.Text color={'blue'} allowFontScaling = {false}>NO</Btn.Text>
</Btn>
</Row>
)}
</View>
这是我的代码,当用户单击是或否按钮时,它应该隐藏这些按钮。它在最后一条消息时工作,但如果在此消息之后有一些消息,它就不起作用。
解决方案
为了解决这个问题,我在屏幕上放置了一个加载器,并使用 API 更新了整个内容。
推荐阅读
- keycloak - 何时在 Keycloak 中使用领域角色?
- pandas - 如何在 Pandas 列中添加数据
- r - 如何从线性回归分析中计算斜率?
- java - 如何将多行字符串转换为行保持缩进数组
- java - 在 Java 中,如何使用 Log.e(或任何函数)列出代码中使用的所有变量
- javascript - 在光滑的滑块中隐藏和显示滑动箭头
- r - 如何生成以R中的序列结尾的字符串列表
- angular - 角火支持PhoneAuthProvider和linkWithCredentials吗?
- android - 如何确定任何 Android 应用程序的图像缩略图大小
- html - 如何在 Visual Studio Code 中同时自动完成 HTML 和 Django-HTML?