Is there a way to remove double borders from overlapping border styles without using map or any other loop? Using loops i could specify index and than style based on that index, but how can i do it without looping?
export function List() {
return (
<ListItem>
<ListItem>
<ListItem>
);
}
export function ListItem() {
return (
<Pressable style={styles.container}></Pressable>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: "pink",
borderTopWidth: 1,
borderBottomWidth: 1,
borderColor: "black",
padding: 20,
},
});
EDITED Right now i am missing the first ListItems top border.
export function ListItem() {
return (
<Pressable style={styles.container, ListItem.length === 0
? styles.bothBorders
: ListItem.length === 0
? styles.onlyTopBorder
: styles.onlyBottomBorder,}></Pressable>
);
}
const styles = StyleSheet.create({
container: {
backgroundColor: "pink",
borderColor: "black",
padding: 20,
},
bothBorders: {
borderBottomWidth: 1,
borderTopWidth: 1,
},
onlyTopBorder: {
borderTopWidth: 1,
},
onlyBottomBorder: {
borderBottomWidth: 1,
},
});

