Reactjs React Native:它到底想把封闭的标签放在哪里?
对于我来说,从Reactjs React Native:它到底想把封闭的标签放在哪里?,reactjs,react-native,Reactjs,React Native,对于我来说,从react native返回的View和Text非常混乱,我现在只想删除显示ADD to CALENDAR的按钮 const EventFeedCard = props => { //prettier-ignore const source = props.event.ImageURL ? {uri: props.event.ImageURL} : defaultImage; //prettier-ignore const contentStyles = d
react native
返回的View
和Text
非常混乱,我现在只想删除显示ADD to CALENDAR的按钮
const EventFeedCard = props => {
//prettier-ignore
const source = props.event.ImageURL ? {uri: props.event.ImageURL} : defaultImage;
//prettier-ignore
const contentStyles = deviceHelpers.isTablet ? feedContentStyles.tabletContent : feedContentStyles.content;
//prettier-ignore
const contentFlexer = deviceHelpers.isTablet ? {flex: 2} : {flex: 1};
//prettier-ignore
const eventLocation = `${props.event.Location.City}, ${props.event.Location.StateAbbreviation}`;
const displayTotal = props.isRegistered && !props.event.IsFree;
return (
<Card style={props.style}>
<View style={feedContentStyles.header}>
<Text style={feedContentStyles.title}>
{`NFIB ${props.event.LegislatureType.toUpperCase()} EVENT`}
</Text>
<Text style={feedContentStyles.postDate}>
{`On ${format(props.event.StartDate, "MMM D, YYYY")}`}
</Text>
</View>
{!deviceHelpers.isTablet && (
<View style={feedContentStyles.feedMainImageContainer}>
<Image source={source} style={feedContentStyles.feedMainImage} />
</View>
)}
<Divider />
<View style={contentStyles}>
{deviceHelpers.isTablet && (
<View style={feedContentStyles.feedMainImageContainerTablet}>
<Image source={source} style={feedContentStyles.feedMainImage} />
</View>
)}
<View style={contentFlexer}>
<Text style={feedContentStyles.contentTitle}>
{props.event.Title}
</Text>
<View style={[styles.detailsRow, { marginBottom: 8 }]}>
<Icon
name="date-range"
size={16}
color="rgba(0,0,0,0.5)"
style={styles.icon}
/>
<EventDate event={props.event} />
</View>
<View style={[styles.detailsRow, { marginBottom: 8 }]}>
<Icon
name="location-on"
size={16}
color="rgba(0,0,0,0.5)"
style={styles.icon}
/>
<Text style={styles.smallerText}>{eventLocation}</Text>
</View>
{displayTotal && (
<View style={[styles.detailsRow, { marginBottom: 8 }]}>
<Icon
name="credit-card"
size={16}
color="rgba(0,0,0,0.54)"
style={styles.icon}
/>
<Text style={styles.smallerText}>{`$${props.grandTotal}`}</Text>
</View>
)}
<Text style={feedContentStyles.parragraph}>
{props.event.ShortDescription}
</Text>
</View>
</View>
{props.isRegistered && <Divider style={styles.dividerPusher} />}
<View style={[feedContentStyles.footerActions, styles.footerActions]}>
// {props.isRegistered &&
// (
// <TouchableOpacity
// style={styles.calendarBtn}
// onPress={props.handleAddToCalendar}
// >
// <Text style={styles.gothamBold14Black}>{"ADD TO CALENDAR"}</Text>
// </TouchableOpacity>
// )
// }
<TextButton
color={v2Colors.green}
title={"VIEW DETAILS"}
titleColor={v2Colors.white}
onPress={props.mainActionButtonPress}
titleStyle={v2ButtonStyles.titleStyle}
/>
</View>
</Card>
);
};
我在整张卡片上包了一个div或碎片,我试过在卡片里面。我需要在哪里包装这个父div?要评论JSX,它需要用大括号包装:
{/* props.isRegistered &&
(
<TouchableOpacity
style={styles.calendarBtn}
onPress={props.handleAddToCalendar}
>
<Text style={styles.gothamBold14Black}>{"ADD TO CALENDAR"}</Text>
</TouchableOpacity>
)
*/}
{/*props.isRegistered&&
(
{“添加到日历”}
)
*/}
什么是“我没有解决它”呢?@MattWay,我澄清了我的说法。谢谢你。对于这行/{props.isRegistered&
,你可以在js{
你能发布产生错误的完整返回代码吗?在你发布错误的地方,我看到了React.Fragment
,它不在你发布的代码中!也试着删掉你所有的评论行,我认为你实际上不能这样评论。是的,在@MattWay提到它之后,我意识到我的评论是不正确的谢谢你。
{/* props.isRegistered &&
(
<TouchableOpacity
style={styles.calendarBtn}
onPress={props.handleAddToCalendar}
>
<Text style={styles.gothamBold14Black}>{"ADD TO CALENDAR"}</Text>
</TouchableOpacity>
)
*/}