2

When i send a message in my react-native application, using react-native-gifted-chat, i get a warning concerning ParsedText (react-native-parsed-text -> https://github.com/taskrabbit/react-native-parsed-text)

Here is the warning i get :

Warning: Failed prop type: Invalid props.style key '0' supplied to 
'ParsedText'.
Bad object: {
    "0": {
        "color":"white",
        "textDecorationLine":"underline"
    },
    "1": {
        "color":"darkturquoise"
    },
    "color":"#A4A4A4"
}

Have you ever had this problem ?

Here is the react-native code :

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 }
    ]}
/>
L.G
  • 1,458
  • 4
  • 14
  • 24
  • I found a correction, this is due to ...linkStyle which has been added in my GiftedChat component parsePatterns property : { pattern: /#(\w+)/, style: { ...linkStyle, color: '#A4A4A4' }, onPress: this.onPressHashtag }, if you delete ...linkStyle, replacing this with : { pattern: /#(\w+)/, style: {textDecorationLine: 'underline', color: '#A4A4A4' }, onPress: this.onPressHashtag } the warning disappears – L.G Jun 19 '19 at 14:45

0 Answers0