警告:prop类型失败:提供给'ParsedText'的props.style键'0'无效

时间:2019-06-19 12:54:59

标签: react-native react-native-gifted-chat

当我在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 }
    ]}
/>

0 个答案:

没有答案