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:
+2
-1
@@ -31,7 +31,8 @@
|
|||||||
{ "iCloudContainerEnvironment": "Production" }
|
{ "iCloudContainerEnvironment": "Production" }
|
||||||
],
|
],
|
||||||
"expo-background-fetch",
|
"expo-background-fetch",
|
||||||
"expo-task-manager"
|
"expo-task-manager",
|
||||||
|
"@maplibre/maplibre-react-native"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ export default function ActivityScreen() {
|
|||||||
const [loadingMap, setLoadingMap] = useState(false);
|
const [loadingMap, setLoadingMap] = useState(false);
|
||||||
const [loadingChart, setLoadingChart] = 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(() => {
|
useEffect(() => {
|
||||||
if (!row) return;
|
if (!row) return;
|
||||||
|
|
||||||
@@ -62,7 +65,8 @@ export default function ActivityScreen() {
|
|||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
.finally(() => setLoadingChart(false));
|
.finally(() => setLoadingChart(false));
|
||||||
}
|
}
|
||||||
}, [row?.id]);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [row?.id, instanceUrl, token]);
|
||||||
|
|
||||||
if (!row) {
|
if (!row) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user