Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6213

conditionally render some items from React-Native FlatList

$
0
0

I am using the React Native FlatList like this:

export const UserList: React.FunctionComponent<UserListProps> = ({  data,  onSendRequest,}) => {  return (<View><FlatList        data={data?.users?.nodes}        horizontal={false}        scrollEnabled        renderItem={({ item }) => (<User user={item} onSendRequest={onSendRequest} />        )}        keyExtractor={(item) => item?.id?.toString()}        ListEmptyComponent={NoUsersContainer}      /></View>  );};

Currently, it renders all items. Is there any way I can introduce some sort of checks inside the Flatlist? For instance, if

data.users.nodes.id == 1

then don't render while all the rest should be rendered. Generally we could do something like this with a ternary operator or if-else statements but I couldn't think of a clean, correct way for FlatLists.


Viewing all articles
Browse latest Browse all 6213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>