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.
This commit is contained in:
Davide Scaini
2026-04-25 09:42:25 +02:00
parent d8b3a69564
commit e08b024d15
2 changed files with 7 additions and 2 deletions
+2 -1
View File
@@ -31,7 +31,8 @@
{ "iCloudContainerEnvironment": "Production" }
],
"expo-background-fetch",
"expo-task-manager"
"expo-task-manager",
"@maplibre/maplibre-react-native"
]
}
}
+5 -1
View File
@@ -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 (