I have been simply trying to render a card from react-native-elements
UI library. Here is the documentation that I’ve been looking through and literally copied and pasted from: https://reactnativeelements.com/docs/1.2.0/card
Here is my Deal
component:
import { View } from 'react-native'
import { Card, ListItem } from 'react-native-elements'
const Deal = () => {
const users = [
{
name: 'brynn',
avatar: 'https://www.w3schools.com/howto/img_avatar2.png',
},
]
return (
<View>
<Card containerStyle={{ padding: 0 }}>
{users.map((u, i) => {
return (
<ListItem
key={i}
roundAvatar
title={u.name}
leftAvatar={{ source: { uri: u.avatar } }}
/>
)
})}
</Card>
</View>
)
}
export default Deal
Here is my SecondScreen
component in which I am trying to render Deal
:
import { StyleSheet, Text, View } from 'react-native'
import Step from '../components/Step'
import MyCarousel from '../components/MyCarousel'
import Ratings from '../components/Ratings'
import Deal from '../components/Deal'
export default function SecondScreen({ route, navigation }) {
const { image } = route.params
return (
<>
<View>
<Text
style={{ fontSize: '16px', marginLeft: 10, marginTop: 15 }}
>
Daily Deals
</Text>
<View
style={{
borderBottomColor: 'black',
borderBottomWidth: StyleSheet.hairlineWidth,
}}
/>
<View style={{ marginTop: 10 }}>
<Deal />
</View>
</View>
</>
)
}
Here is what it renders at the end:
Any help would be appreciated!
Edit: I have decided to use another component in the meantime. This seems like possibly deprecated component or something.
2
Answers
Try adding
flex
orheight
for<View />
Inside your
Deal
component, you have a<View />
wrapper around the<Card />
component. The one insideDeal
file, NOT the one wrapping it inSecondScreen
file.Have you tried removing that excess
<View />
?If you want to keep that
<View />
, have you tried giving that specific<View />
astyle={{ height: 100px }}
orstyle={{ flex: 1 }}
property?