当尝试从“react-native-gifted-chat”导入和使用 GiftedChat 组件时,我收到此错误:
Invariant Violation: Tried to register two views with the same name RNCSafeAreaProvider, js engine: hermes
我已经尝试过这里列出的几件事。人们似乎对与“react-native-safe-area-context”相关的其他软件包也有类似的问题。
我没有使用 expo,但我使用的是 React Native CLI。
在我看来,问题出在“react-native-gifted-chat”上。
细节:
如果有人有任何想法或见解,我将不胜感激。如果我找到解决方案,我会将其作为评论发布。
react-native react-native-gifted-chat react-native-safe-area-view
只是想分享。
我发现很难为这个包自定义默认 UI。官方文档没有那么有用。
幸运的是,我能够解决它。
查看答案
我正在为我的一个项目使用 React Native Gifted Chat。我知道有一个图像选项可用,我可以将单个图像附加到聊天中。但是,有没有办法可以将多个图像附加到单个聊天中?
我使用react-native-gifted-chat 进行聊天。我想更改时间字体颜色。我按照医生说的改变了它,但它没有改变。我希望两个时间的颜色都是黑色。使用“react-native-gifted-chat”:“^0.16.1”
const renderTime = (props) => {
return (
<Time
{...props}
textStyle={{
left: {
color: 'black',
},
right: {
color: 'black',
},
}}
/>
);
};
Run Code Online (Sandbox Code Playgroud) 我正在使用有天赋的聊天库,并希望在初始渲染时使用键盘自动聚焦于输入。我看到有一个命令式函数,focusTextInput
但我该如何调用它?
<GiftedChat
{...props}
messages={this.state.messages}
ref={(chat) => this.chat = chat }
onSend={messages => this.onSend(messages)}
user={{
_id: 1,
}}
/>
Run Code Online (Sandbox Code Playgroud)
我尝试设置ref
并直接在 do mount 上调用它,但这没有用。
我想将Card组件添加到此模块:https : //snack.expo.io/@xcarpentier/gifted-chat(演示)
例如,如果onLongPress()
在气泡消息上使用,我希望显示其他信息(在气泡消息的正下方,作为小卡片,例如Tinder卡)。
我怎么做?我是否需要克隆源代码,然后对其进行修改以适合我的需要?
我已经使用天才聊天库在 React Native 中开发了聊天视图。但我想在点击聊天气泡时执行删除操作。
我尝试过自定义 renderCustomView 、lightboxProps 和 onLongPress 道具,但都没有工作。