Memoize, lint
This commit is contained in:
@@ -124,6 +124,7 @@ export function FeedsTabBar(
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
tabBar: {
|
||||
// @ts-ignore web-only
|
||||
position: isWeb ? 'fixed' : 'absolute',
|
||||
zIndex: 1,
|
||||
left: 0,
|
||||
|
||||
@@ -139,9 +139,12 @@ export const FlatList = React.forwardRef(function FlatListImpl<ItemT>(
|
||||
<View
|
||||
style={[styles.contentContainer, contentContainerStyle, pal.border]}>
|
||||
{(data as Array<ItemT>).map((item, index) => (
|
||||
<View key={keyExtractor!(item, index)}>
|
||||
{renderItem!({item, index, separators: null as any})}
|
||||
</View>
|
||||
<Row<ItemT>
|
||||
key={keyExtractor!(item, index)}
|
||||
item={item}
|
||||
index={index}
|
||||
renderItem={renderItem}
|
||||
/>
|
||||
))}
|
||||
{onEndReached && (
|
||||
<Tail threshold={onEndReachedThreshold} onVisible={onVisible} />
|
||||
@@ -151,6 +154,25 @@ export const FlatList = React.forwardRef(function FlatListImpl<ItemT>(
|
||||
)
|
||||
})
|
||||
|
||||
let Row = function RowImpl<ItemT>({
|
||||
item,
|
||||
index,
|
||||
renderItem,
|
||||
}: {
|
||||
item: ItemT
|
||||
index: number
|
||||
renderItem:
|
||||
| null
|
||||
| undefined
|
||||
| ((data: {index: number; item: any; separators: any}) => React.ReactNode)
|
||||
}): React.ReactNode {
|
||||
if (!renderItem) {
|
||||
return null
|
||||
}
|
||||
return renderItem({item, index, separators: null as any})
|
||||
}
|
||||
Row = React.memo(Row)
|
||||
|
||||
let Tail = ({
|
||||
threshold = 0,
|
||||
onVisible,
|
||||
|
||||
@@ -436,6 +436,7 @@ export function DesktopLeftNav() {
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
leftNav: {
|
||||
// @ts-ignore web only
|
||||
position: 'fixed',
|
||||
top: 10,
|
||||
// @ts-ignore web only
|
||||
|
||||
Reference in New Issue
Block a user