ListItem rightTitle propType should be PropTypes.any(or object) instead of PropTypes.string
See original GitHub issueDescription
I’m not a expert of React and RN, so It could be my mistake.
If it isn’t a bug or a issue, close this issue please.
When using nested Text components for the rightTitle prop of ListItem, I get a PropTypes warning because it expects only a string. The underlying TextElement component allows its children to be PropTypes.any, so shouldn’t the ListItem allow rightTitle to be PropTypes.any also?
I’m using version 0.17.0
Reproduction Steps and Sample Code
const rightTitle = (
<View width={50} height={20}>
<Text>{Title}</Text>
<Text>{Subtitle}</Text>
</View>
)
<ListItem ... otherProps rightTitle={rightTitle} />
Solution
it could just change the propType of rightTitle to PropTypes.any in ListItem.js.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top Results From Across the Web
Typechecking With PropTypes - React
To run typechecking on the props for a component, you can assign the special propTypes property: import PropTypes from 'prop-types'; class Greeting extends ......
Read more >Allow different types of PropTypes for one prop - Stack Overflow
I have a component that receives a prop for its size. The prop can be either a string or a number ...
Read more >How to validate React props using PropTypes - LogRocket Blog
Learn how to validate props with React PropTypes, React's internal mechanism for adding type checking to component props.
Read more >How To Use PropTypes In React - Web Dev Simplified Blog
The most basic way you can check a prop's type is by checking to see if it is one of the primitive types...
Read more >How to Use PropTypes in React - freeCodeCamp
We can use PropTypes to validate any data we are receiving from props. ... String. PropType.string. “helllo”. Object. PropType.object.
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 Free
Top 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
It’s a feature that should be added in
v1
of our library. Right now theListItem
component is being completely rewritten to be more flexible. Can see the progress here.Should be released with
beta4
https://github.com/react-native-training/react-native-elements/milestone/2@iRoachie well here is a workaround until the component gets added if you need a subtitle for the rightTitle.