Invalid prop `color` supplied to `Text`
See original GitHub issueWhat I did
I upgraded from React Native 0.62.2 to the latest version 0.63.1 by following this helper. After rebuilt and run the app, everything was working as expected except this warning:
Failed prop type: Invalid prop `color` supplied to `Text`.
I found that this warning was triggered on any page importing Button
element from react-native-element
package. Here is my code:
import {Button} from 'react-native-elements'
<Button
title="Press Me"
containerStyle={styles.buttonContainer}
buttonStyle={styles.buttonStyle}
/>
const styles = StyleSheet.create({
buttonContainer: {
alignSelf: 'center',
position: 'absolute',
bottom: 50,
},
buttonStyle: {
backgroundColor: '#3282b8',
width: 231,
},
})
Expected behavior
The button is shown on the simulator without warning prompt.
Error log
Warning: Failed prop type: Invalid prop `color` supplied to `Text`: hsl(208, 8%, 63%)
Valid color formats are
- '#f0f' (#rgb)
- '#f0fc' (#rgba)
- '#ff00ff' (#rrggbb)
- '#ff00ff00' (#rrggbbaa)
- 'rgb(255, 255, 255)'
- 'rgba(255, 255, 255, 1.0)'
- 'hsl(360, 100%, 100%)'
- 'hsla(360, 100%, 100%, 1.0)'
- 'transparent'
- 'red'
- 0xff00ff00 (0xrrggbbaa)
Bad object: {
"color": {
"model": "hsl",
"color": [
208,
8,
63
],
"valpha": 1
},
"fontSize": 18,
"textAlign": "center",
"paddingTop": 2,
"paddingBottom": 1
}
Screenshots
My Environment:
software | version |
---|---|
react-native-elements | 2.0.4 |
react-native | 0.63.1 |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Invariant Violation: Invalid prop 'color' supplied - Stack Overflow
i believe you are using styles.myText in some other component like View or something , hence color is not a style attribute there,...
Read more >Invariant Violation: Invalid prop 'color' supplied-React Native
Coding example for the question Invariant Violation: Invalid prop 'color' supplied-React Native.
Read more >invalid prop `color` supplied to `text`: black.600 - Code Grepper
ERROR Warning: Failed prop type: Invalid props.starStyle key `color` supplied ... You have to set the color style directly on a Text component...
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 >How to Use PropTypes in React - freeCodeCamp
Props [https://tekolio.com/what-are-props-in-react-and-how-to-use-them ... return new Error( "Invalid prop `" + propName + "` supplied to" + ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did some digging on this and I think the culprit is the color() method from the color package. It seems to be returning an object instead of a string, which is getting passed to Text and causing the error. Adding
.string()
to the call chains on lines 231 and 235 in Button.js seems to have fixed it for me locally:Not sure how many other components may suffer from the same issue though. Fortunately though, it seems like a relatively easy fix.
@timecatalyst awesome! Thank you very much for the PR. I’ll review it soon.