Repository navigation
fix: keep live markers on renderCluster switch - #238
Conversation
Switching renderCluster while the map was showing removed every marker
and published an empty render state, so MapView unmounted every live
MarkerView, including on-screen ones with clusterable={false}, and
remounted them with fresh React state.
Only clusters change hands between the SDK and JS. The registry now
drops just its JSX clusters, and each controller (Android, MapKit,
Google iOS) removes just its SDK clusters before reapplying, so markers
are not touched.
A refresh request carried the displayed versions from when it was scheduled. The index build replays the latest request, so a gesture refresh applied while the index was being rebuilt (after a renderCluster or clusteringEnabled switch) was replayed against a snapshot from before it, and every annotation it had added was added again. applyDiff overwrote displayedAnnotations[key], leaving the first annotation on the map. The pipeline now takes the displayed versions as a closure and reads them when each request is built, as Android already does.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
React Doctor found 4 issues in 2 files · 1 error & 3 warnings · score 81 / 100 (Needs work) · full project Errors
3 warnings
Reviewed by React Doctor for commit |
|
@coderabbitai review |
Action performed
|
What does this change?
Fixes the two follow-ups from the review of #74 in #229. Both happen when
renderClusteris turned on or off while the map is showing.Closes #229
1. Live markers lose their state. The switch removed every marker and published an empty render state, so
MapViewunmounted every liveMarkerView, including on-screen ones withclusterable={false}, and remounted them with fresh React state. Only clusters change hands between the SDK and JS. Now:MarkerViewRenderRegistry.setCustomClusters(Kotlin and Swift) drops only its JSX clusters.MapClusterAnnotations; on Google iOS, markers with a.clusterpayload; on Android,clusterByKey(with their entering animations).2. iOS: a queued refresh could add an annotation twice.
MarkerRenderPipelinestored the displayed versions in each request when it was scheduled, and the index build replays the latest request (latestRefreshParameters). One ordering that adds everything twice:applyDiffoverwritesdisplayedAnnotations[key], so the first annotation stayed on the map. The pipeline now takesdisplayedVersionsas a closure and reads it when each request is built, as Android already does. AclusteringEnabledswitch could take the same path and is covered too.I didn't add a guard in
applyDiffagainst an existing key: with the snapshot fixed it can't happen, and a guard would hide the next bug of this kind.How was it verified?
switching renderCluster hands back only the JSX clusters: fails on main, passes here. All 235 Android unit tests pass, and:react-native-better-maps:assembleDebugbuilds.clusterable={false}MarkerViewshowing a random id picked on mount, withrenderClusterswitched every 5 s on the Live JSX markers scenario.GOOGLE_MAPS_IOS_API_KEY. Google on iOS was not run.bun run lint,bun run typecheckandbun run buildpass.Scope
Checklist
bun run lint,bun run typecheckandbun run buildpassrenderClusterno longer remounts live markers, and SDK markers no longer replay their entering animation on the switch.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.