diff options
-rw-r--r-- | src/components/search/SearchResultList.tsx | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/components/search/SearchResultList.tsx b/src/components/search/SearchResultList.tsx index 32caa764..fe32ef65 100644 --- a/src/components/search/SearchResultList.tsx +++ b/src/components/search/SearchResultList.tsx @@ -25,14 +25,15 @@ const SearchResultList: React.FC<SearchResultsProps> = ({ results, keyboardVisible, }) => { - const [showSection, setShowSection] = useState(true); const [showEmptyView, setshowEmptyView] = useState(false); const {user: loggedInUser} = useSelector((state: RootState) => state.user); useEffect(() => { if (results && results.length > 0) { setshowEmptyView( - results[0].data.length === 0 && results[1].data.length === 0, + results[0].data.length === 0 && + results[1].data.length === 0 && + results[2].data.length === 0, ); } }, [results]); @@ -62,14 +63,9 @@ const SearchResultList: React.FC<SearchResultsProps> = ({ /> ); }} - renderSectionHeader={({section: {title, data}}) => { - if (['categories', 'badges'].includes(title) && data.length === 0) { - setShowSection(false); - } - return sectionHeader( - ['users', 'categories'].includes(title) && showSection, - ); - }} + renderSectionHeader={({section: {data}}) => + sectionHeader(data.length !== 0) + } /> )} </View> |