Warning: Failed prop type: Invalid props.style key '0' supplied to 'ParsedText'
See original GitHub issueIssue Description
When i send a message in my react-native application, using react-native-gifted-chat, i get a warning concerning ParsedText.
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” }
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 } ]} />
Steps to Reproduce / Code Snippets
Send a message in the chat
Expected Results
No warning
Additional Information
- React version: 16.8.3
- React Native version: 0.59.4
- react-native-gifted-chat version: 0.9.6
- Platform(s) (iOS, Android, or both?): Android
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
A more correct way to fix it would be to swap {…linkStyle} for Object.assign({}, …linkStyle). This is because linkstyle is an array of objects. @FaridSafi would be good if you could update the example in the readme.
remove …linkStyle in your code