Gabotronix's avatar

React Native: renderItem component to Custom FlatList as a prop? (like Vue slots)

Hi everybody, I want to have a reusable FlatList component, basically a wrapper I can pass a custom component as an item to render, and I want to pass this component as props, this is easily done in vue..js with scoped/slots.

Is there a way to do this in react native?

<View style={{ flex:1 }}>
        <FlatList  style={{ width:'100%'}}  data={props.data} keyExtractor={item => item.id.toString()}
            renderItem={({ item, index }) => 
            <PropComponent item={item}></PropComponent>}
        />
    </View>

In example above PropComponent would be passed to CustomFlatList like this:

<CustomFlatList>
     <PropComponent></PropComponent>
</CustomFlatList>
```
0 likes
0 replies

Please or to participate in this conversation.