diff --git a/screens/FindScreen.js b/screens/FindScreen.js index a83a4a5..abbf46f 100644 --- a/screens/FindScreen.js +++ b/screens/FindScreen.js @@ -336,6 +336,23 @@ const FindScreen = ({navigation}) => { } } }, [filterFormatSearch]) + + function abortNetworkRequests() { + abortControllerRef.current.abort(); + abortControllerRef.current = new AbortController() + } + + function changeToUsers() { + abortNetworkRequests(); + setChangeSectionsOne([]) + setFilterFormatSearch("Users") + } + + function changeToCategories() { + abortNetworkRequests(); + dispatchCategories({type: 'resetCategories'}) + setFilterFormatSearch("Categories"); + } return( <> @@ -348,56 +365,21 @@ const FindScreen = ({navigation}) => { Users - {filterFormatSearch == "Users" && ( - - - - )} - {filterFormatSearch !== "Users" && ( - { - abortControllerRef.current.abort(); - abortControllerRef.current = new AbortController() - setChangeSectionsOne([]) - setFilterFormatSearch("Users") - }}> - - - )} + filterFormatSearch !== 'Users' ? changeToUsers() : null}> + + Categories - {filterFormatSearch == "Categories" && ( - - - - )} - {filterFormatSearch !== "Categories" && ( - { - abortControllerRef.current.abort(); - abortControllerRef.current = new AbortController(); - dispatchCategories({type: 'resetCategories'}) - setFilterFormatSearch("Categories"); - }}> - - - )} + filterFormatSearch !== 'Categories' ? changeToCategories() : null}> + + Images - {filterFormatSearch == "Images" && ( - - - - )} - {filterFormatSearch !== "Images" && ( - { - //setChangeSections([]) - //setFilterFormatSearch("Images") - alert('This feature is coming soon') - }}> - - - )} + alert('This feature is coming soon')}> + +