From 98bd8dcfb88ec0f2a83672589950a68e0422000f Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Wed, 19 Jul 2023 17:57:25 +0800 Subject: [PATCH] Potential fix to expo-location crash --- src/routes/Home/Home.tsx | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx index 39015a6..b4f0846 100644 --- a/src/routes/Home/Home.tsx +++ b/src/routes/Home/Home.tsx @@ -23,22 +23,23 @@ export default function Home() { latitudeDelta: 0.000235, longitudeDelta: 0.000067, }; - async function requestLocation() { - let { status } = await Location.requestForegroundPermissionsAsync(); - if (status !== "granted") { - setFeedback( - "Permission to access location was denied. Please allow permission" - ); - return; - } - if (status == "granted") { - let location = await Location.getCurrentPositionAsync({}); - if (location) { - setLocation(location); - getDistance(location); + setTimeout(async () => { + const { status } = await Location.requestForegroundPermissionsAsync(); + if (status !== "granted") { + setFeedback( + "Permission to access location was denied. Please allow permission" + ); + return; } - } + if (status == "granted") { + let location = await Location.getCurrentPositionAsync({}); + if (location) { + setLocation(location); + getDistance(location); + } + } + }, 2000); } useEffect(() => { requestLocation();