add support for ListEmptyComponent, allow undefined data
This commit is contained in:
@@ -38,6 +38,7 @@ function ListImpl<ItemT>(
|
|||||||
{
|
{
|
||||||
ListHeaderComponent,
|
ListHeaderComponent,
|
||||||
ListFooterComponent,
|
ListFooterComponent,
|
||||||
|
ListEmptyComponent,
|
||||||
containWeb,
|
containWeb,
|
||||||
contentContainerStyle,
|
contentContainerStyle,
|
||||||
data,
|
data,
|
||||||
@@ -92,6 +93,16 @@ function ListImpl<ItemT>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let emptyComponent: JSX.Element | null = null
|
||||||
|
if (ListEmptyComponent != null) {
|
||||||
|
if (isValidElement(ListEmptyComponent)) {
|
||||||
|
emptyComponent = ListEmptyComponent
|
||||||
|
} else {
|
||||||
|
// @ts-ignore Nah it's fine.
|
||||||
|
emptyComponent = <ListEmptyComponent />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (headerOffset != null) {
|
if (headerOffset != null) {
|
||||||
style = addStyle(style, {
|
style = addStyle(style, {
|
||||||
paddingTop: headerOffset,
|
paddingTop: headerOffset,
|
||||||
@@ -331,7 +342,9 @@ function ListImpl<ItemT>(
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{header}
|
{header}
|
||||||
{(data as Array<ItemT>).map((item, index) => {
|
{!data || data.length === 0
|
||||||
|
? emptyComponent
|
||||||
|
: (data as Array<ItemT>)?.map((item, index) => {
|
||||||
const key = keyExtractor!(item, index)
|
const key = keyExtractor!(item, index)
|
||||||
return (
|
return (
|
||||||
<Row<ItemT>
|
<Row<ItemT>
|
||||||
|
|||||||
Reference in New Issue
Block a user