From b39fc67038e3438e263ee04620e6d344d8f537cb Mon Sep 17 00:00:00 2001 From: Amaury <1293565+amaurym@users.noreply.github.com> Date: Tue, 2 Mar 2021 22:22:03 +0100 Subject: [PATCH] fix: Fix setting null/undefined value in AsyncStorage (#912) --- App/stores/location.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/App/stores/location.tsx b/App/stores/location.tsx index 1714e0b5..b5bceef5 100644 --- a/App/stores/location.tsx +++ b/App/stores/location.tsx @@ -148,9 +148,12 @@ export function LocationContextProvider({ }, []); // eslint-disable-line react-hooks/exhaustive-deps useEffect(() => { - AsyncStorage.setItem( - LAST_KNOWN_LOCATION_KEY, - JSON.stringify(currentLocation) + (currentLocation + ? AsyncStorage.setItem( + LAST_KNOWN_LOCATION_KEY, + JSON.stringify(currentLocation) + ) + : AsyncStorage.removeItem(LAST_KNOWN_LOCATION_KEY) ).catch(sentryError('LocationContextProvider')); }, [currentLocation]);