Only show the View component if recent is true: const recent = new Date() - data.date <…
- User
Only show the View component if recent is true:
const recent = new Date() - data.date < 86400000; return ( // style={style} <View style={{ paddingLeft: 16, flexDirection: 'row', alignItems: 'center' }}> <Icon source="alert-circle-outline" color={'grey'} size={50} /> <Card.Title style={{ flexDirection: 'column' }} title={data.title} subtitle={(new Date() - data.date < 86400000) && getTimeAgo(data.date)} /> <Card.Content> {data.caption} </Card.Content> {/* <Card.Cover source={{ uri: 'https://picsum.photos/700' }} /> */} <Card.Actions> <Button onPress={() => console.log('Pressed')}>Cancel Ok </Card.Actions>
(react native)
- Assistant
To conditionally render the
Viewcomponent only ifrecentis true, you can use a conditional statement within the JSX. Here is how your code can be modified to achieve that:jsx