From c1f7bfb8051b841392c02a3edd5f1f99746956ee Mon Sep 17 00:00:00 2001 From: whysman Date: Sun, 27 Apr 2025 14:58:11 -0400 Subject: [PATCH] store park variable, clear prior search values --- components/Location.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/components/Location.tsx b/components/Location.tsx index ad14bfa..a9222eb 100644 --- a/components/Location.tsx +++ b/components/Location.tsx @@ -36,7 +36,7 @@ const LocationScreen: React.FC = ({ visible, currentTheme, const [locLoading, setLocLoading] = useState(false); const [parks, setParks] = useState([]); const [hasSearched, setHasSearched] = useState(false); - const [selectedParkId, setSelectedParkId] = useState(null); + const [selectedPark, setSelectedPark] = useState(null); // Call the parks endpoint with coordinates const fetchNearbyParks = async (longitude: number, latitude: number) => { @@ -104,15 +104,14 @@ const LocationScreen: React.FC = ({ visible, currentTheme, }} titleStyle={{ fontWeight: "bold" }} descriptionNumberOfLines={2} - onPress={() => setSelectedParkId(item.Id)} + onPress={() => { + setSelectedPark(item); + setParks([]); + setHasSearched(false); + }} /> ); - // Find the selected park, if one is selected - const selectedPark = selectedParkId - ? parks.find(p => p.Id === selectedParkId) - : null; - return ( = ({ visible, currentTheme, />