isFirst를 boolean type으로 가정한다.
{/* Experience */}
<View style={styles.section}>
<Text style={styles.sectionTitle}>Experience</Text>
{user.experience?.map((experience, index) => (
<ExperienceListItem key={experience.id} experience={experience} isFirst={index === 0} />
))}
</View>
export default function ExperienceListItem({
experience,
isFirst,
}: ExperienceListItemProps) {
return (
<View style={styles.container}>
<Image source={{ uri: experience.companyImage }} style={styles.image} />
<Text style={styles.title}>{experience.title}</Text>
<Text>{experience.companyName}</Text>
</View>
);
}
type ExperienceListItemProps = {
experience: Experience;
isFirst: boolean;
};
export default function ExperienceListItem({
experience,
isFirst,
}: ExperienceListItemProps) {
return (
<View
style={[
styles.container,
{ backgroundColor: isFirst ? "lightgray" : "white" },
]}
>
<Image source={{ uri: experience.companyImage }} style={styles.image} />
<Text style={styles.title}>{experience.title}</Text>
<Text>{experience.companyName}</Text>
</View>
);
}
<View
style={[
styles.container,
{ backgroundColor: isFirst ? "lightgray" : "white" },
]}
>
'개발 > React Native' 카테고리의 다른 글
Stepzen과 neon을 이용해 Postgresql과 graphQL 쉽게 사용하기 (0) | 2023.08.11 |
---|---|
GraphQL vs REST API (0) | 2023.08.02 |
안드로이드 스튜디오 맥북 M1 에뮬레이터 안 켜질 때 해결 방법 (0) | 2023.07.26 |
Xcode에서 Components가 없어졌을 때 찾는 방법 (0) | 2023.07.25 |