Match FL semantics

This commit is contained in:
Dan Abramov
2023-12-23 02:33:10 +00:00
parent d6e9ce83fb
commit d9c44c373a
+9 -9
View File
@@ -1,4 +1,4 @@
import React, {memo, useRef, startTransition} from 'react' import React, {isValidElement, memo, useRef, startTransition} from 'react'
import {FlatListProps, StyleSheet, View, ViewProps} from 'react-native' import {FlatListProps, StyleSheet, View, ViewProps} from 'react-native'
import {addStyle} from 'lib/styles' import {addStyle} from 'lib/styles'
import {usePalette} from 'lib/hooks/usePalette' import {usePalette} from 'lib/hooks/usePalette'
@@ -56,21 +56,21 @@ function ListImpl<ItemT>(
let header: JSX.Element | null = null let header: JSX.Element | null = null
if (ListHeaderComponent != null) { if (ListHeaderComponent != null) {
if (typeof ListHeaderComponent === 'object') { if (isValidElement(ListHeaderComponent)) {
header = ListHeaderComponent header = ListHeaderComponent
} else if (typeof ListHeaderComponent === 'function') { } else {
// @ts-ignore We aren't using classes so it's a render function. // @ts-ignore Nah it's fine.
header = ListHeaderComponent() header = <ListHeaderComponent />
} }
} }
let footer: JSX.Element | null = null let footer: JSX.Element | null = null
if (ListFooterComponent != null) { if (ListFooterComponent != null) {
if (typeof ListFooterComponent === 'object') { if (isValidElement(ListFooterComponent)) {
footer = ListFooterComponent footer = ListFooterComponent
} else if (typeof ListFooterComponent === 'function') { } else {
// @ts-ignore We aren't using classes so it's a render function. // @ts-ignore Nah it's fine.
footer = ListFooterComponent() footer = <ListFooterComponent />
} }
} }