当我在react-native应用程序中使用react-native-gifted-chat发送消息时,会收到有关ParsedText的警告(react-native-parsed-text-> https://github.com/taskrabbit/react-native-parsed-text)
这是我得到的警告:
Warning: Failed prop type: Invalid props.style key '0' supplied to
'ParsedText'.
Bad object: {
"0": {
"color":"white",
"textDecorationLine":"underline"
},
"1": {
"color":"darkturquoise"
},
"color":"#A4A4A4"
}
您遇到过这个问题吗?
这是反应本机代码:
renderMessageText(messageTextProps) {
return (
<MessageText
{...messageTextProps}
linkStyle={{
left: { color: 'darkturquoise' },
right: { color: 'darkturquoise' }
}}
/>
);
}
<GiftedChat
messages={this.state.messages}
onSend={this.onSend}
user={user}
showUserAvatar={true}
renderUsernameOnMessage={true}
showAvatarForEveryMessage={true}
renderMessageText={this.renderMessageText}
parsePatterns={(linkStyle) => [
{ pattern: /#(\w+)/, style: { ...linkStyle, color: '#A4A4A4' }, onPress: this.onPressHashtag }
]}
/>