Open AnasAlamin opened 3 years ago
use conditionals in the FlatList
renderItem
property
example:
<FlatList
// ...
renderItem={({ item }) => {
const listItem = <Text>{item.content}</Text>;
if (item.type === "render_tourguide") {
return <TourGuideZone /* ... */>{listItem}</TourGuideZone>;
}
return listItem;
}}
/>
The render Item function provides an index, check if index === 0 then wrap the item.
I'm using something like this:
<TourGuideZone isTourGuide={info.index === 0} /* ... */>{...}</TourGuideZone>
However the position of the zone is a bit off
i have a flatlist and i want to wrap only one the first item in it. how can i do that?