Component - Item separators
This UI component shows a list of items with clear lines between each item. These lines, called item separators, help users see where one item ends and the next begins, making the list easier to read.
This UI component shows a list of items with clear lines between each item. These lines, called item separators, help users see where one item ends and the next begins, making the list easier to read.
View ├─ FlatList │ ├─ renderItem (Text) │ └─ ItemSeparatorComponent (View) └─ (optional) SafeAreaView
ItemSeparatorComponent in a FlatList in React Native?ItemSeparatorComponentFlatList?ItemSeparatorComponent in FlatList.ItemSeparatorComponent={() => <View style={{height: 1, backgroundColor: 'gray'}} />} -> Option CItemSeparatorComponent={() => <View style={{height: 1, backgroundColor: 'gray'}} />} [OK]FlatList?
const data = ['Apple', 'Banana', 'Cherry'];
<FlatList
data={data}
renderItem={({item}) => <Text>{item}</Text>}
ItemSeparatorComponent={() => <View style={{height: 2, backgroundColor: 'black'}} />}
/>View with height 2 and black background, so a thin black line.FlatList code that tries to add separators?
<FlatList
data={[1,2,3]}
renderItem={({item}) => <Text>Item {item}</Text>}
ItemSeparatorComponent="<View style={{height: 1, backgroundColor: 'gray'}} />"
/>FlatList with vertical items and a custom separator that is a 10-pixel tall red line with 20 pixels horizontal margin on each side. Which code snippet correctly implements this separator?marginHorizontal: 20 to add space on left and right sides.Pass the test and this pattern moves unknown