Skip to content

Commit

Permalink
Implement flat list but still slow af
Browse files Browse the repository at this point in the history
  • Loading branch information
adityapawar1 committed Dec 3, 2023
1 parent 96f9a53 commit 1cf5bdd
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/components/FilterModal/FilterModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BottomSheet, CheckBox } from '@rneui/themed';
import { useCallback, useState } from 'react';
import { View, Text, ScrollView, Pressable } from 'react-native';
import { View, Text, ScrollView, Pressable, FlatList } from 'react-native';
import { SafeAreaProvider } from 'react-native-safe-area-context';

import 'react-native-gesture-handler';
Expand Down Expand Up @@ -57,12 +57,10 @@ function FilterModal({ isVisible, setIsVisible, title }: FilterModalProps) {
</View>
<View style={styles.textContainer}>
<Text style={styles.modalTitle}> {title} </Text>
<ScrollView
showsVerticalScrollIndicator
bounces={true}
style={styles.scrollView}
>
{Array.from(filters).map(([_, parentFilter]) => {
<FlatList
data={Array.from(filters)}
renderItem={({ item }) => {
const [_, parentFilter] = item;
return (
<>
<ParentFilter
Expand All @@ -72,20 +70,23 @@ function FilterModal({ isVisible, setIsVisible, title }: FilterModalProps) {
onPress={toggleParentFilter}
/>

{parentFilter.children.map(filter => {
return (
<ChildFilter
id={filter.id}
name={filter.name}
checked={filter.active}
onPress={toggleChildFilter}
/>
);
})}
<FlatList
data={parentFilter.children}
renderItem={({ item }) => {
return (
<ChildFilter
id={item.id}
name={item.name}
checked={item.active}
onPress={toggleChildFilter}
/>
);
}}
/>
</>
);
})}
</ScrollView>
}}
/>
</View>
</View>
</BottomSheet>
Expand Down

0 comments on commit 1cf5bdd

Please sign in to comment.