question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning: Failed prop type: Invalid props.style key '0' supplied to 'ParsedText'

See original GitHub issue

Issue 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:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
Miyoucommented, Nov 12, 2019

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.

1reaction
LG1710commented, Jul 9, 2019

remove …linkStyle in your code

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Failed prop type: Invalid props.style key '0' supplied ...
When i send a message in my react-native application, using react-native-gifted-chat, i get a warning concerning ParsedText ...
Read more >
Invalid props.style key 'textAlign' supplied to 'View'-Reactjs
Coding example for the question Failed prop type: Invalid props.style key 'textAlign' supplied to 'View'-Reactjs.
Read more >
A brand new website interface for an even better experience!
Warning : Failed prop type: Invalid props.style key `color` supplied to `Icon`.
Read more >
Warning: Failed prop type: Invalid prop `children` supplied to ...
Warning : Failed prop type: Invalid prop `children` supplied to `ForwardRef(Typography)`, expected a ReactNode. */<Typography key={item.id}>
Read more >
How to Use PropTypes in React - freeCodeCamp
Props are the read-only properties that are shared between components to give the unidirectional flow of React a dynamic touch. They're mainly ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found