From e08b024d1597307ea0d23ee0b0107282f21468e8 Mon Sep 17 00:00:00 2001 From: Davide Scaini Date: Sat, 25 Apr 2026 09:42:25 +0200 Subject: [PATCH] fix: add instanceUrl+token to useEffect deps; add MapLibre Expo plugin In Hermes release builds, useEffect captures closure values from the first render. If instanceUrl or token were empty at that moment (before SQLite reads complete), no fetch ran and map/graphs never loaded. Adding them to the dependency array ensures the effect re-runs once the values are available; guards on existing geojson/timeseries state prevent double-fetching. Also add @maplibre/maplibre-react-native to the Expo plugins array so that expo prebuild applies the library's required Gradle property configuration to the Android project. --- mobile/app.json | 3 ++- mobile/app/activity/[id].tsx | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mobile/app.json b/mobile/app.json index e374ce0..1e84ebf 100644 --- a/mobile/app.json +++ b/mobile/app.json @@ -31,7 +31,8 @@ { "iCloudContainerEnvironment": "Production" } ], "expo-background-fetch", - "expo-task-manager" + "expo-task-manager", + "@maplibre/maplibre-react-native" ] } } diff --git a/mobile/app/activity/[id].tsx b/mobile/app/activity/[id].tsx index 3d73e70..dd22815 100644 --- a/mobile/app/activity/[id].tsx +++ b/mobile/app/activity/[id].tsx @@ -34,6 +34,9 @@ export default function ActivityScreen() { const [loadingMap, setLoadingMap] = useState(false); const [loadingChart, setLoadingChart] = useState(false); + // instanceUrl and token are in the dep array to avoid a stale-closure bug in + // release builds: Hermes executes effects sooner and captures empty strings if + // the deps are omitted. Guards on geojson/timeseries prevent double-fetching. useEffect(() => { if (!row) return; @@ -62,7 +65,8 @@ export default function ActivityScreen() { .catch(() => {}) .finally(() => setLoadingChart(false)); } - }, [row?.id]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [row?.id, instanceUrl, token]); if (!row) { return (