I have a file json but sometimes this file json doesn't have the image.
Sometimes this item this empty: item.better_featured_image.media_details.sizes.medium.source_url
render() {
const { loading, posts } = this.state;
if (loading) {
return (
<View style={styles.container}>
<Text>Cargando .....</Text>
</View>
);
}
categorie_title = this.props.navigation.getParam("categorie_name");
return (
<View>
<FlatList
data={this.state.posts}
renderItem={({ item }) => (
<TouchableOpacity
onPress={() =>
this.props.navigation.navigate("Noticia", {
post_id: item.id,
})
}
>
<Card>
<Card.Content>
<Title>{item.title.rendered}</Title>
</Card.Content>
<Card.Cover
source={{
uri:
item.better_featured_image.media_details.sizes.medium
.source_url
}}
/>
<Card.Content>
<HTML html={item.excerpt.rendered} />
</Card.Content>
</Card>
</TouchableOpacity>
)}
keyExtractor={item => item.id.toString()}
/>
</View>
);
}
I just need a conditional - if
.
The question was if this component item.better_featured_image.media_details.sizes.medium.source_url
is empty, don't show the image.