Skip to content

Instantly share code, notes, and snippets.

@aleksejkozin
Last active January 13, 2021 21:47
Show Gist options
  • Save aleksejkozin/3a5696e0ca050f2aad15930f9d9e0e46 to your computer and use it in GitHub Desktop.
Save aleksejkozin/3a5696e0ca050f2aad15930f9d9e0e46 to your computer and use it in GitHub Desktop.
import React from 'react'
import {FlatList, FlatListProps, Text} from 'react-native'
import LoadingIndicator from './LoadingIndicator'
export type UIFriendlyListProps<T> = FlatListProps<T> & {loading?: boolean}
export function UIFriendlyList<T>(props: UIFriendlyListProps<T>) {
if (props.loading) {
return <LoadingIndicator />
}
if (props?.data && props.data.length === 0) {
return <Text>This list is empty (</Text>
}
return <FlatList {...props} />
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment