openmobilehub / react-native-omh-maps

https://openmobilehub.github.io/react-native-omh-maps/
Apache License 2.0
23 stars 0 forks source link

fix: null pointer exception on old arch when unmounting entites after unmounting map fragment #19

Closed artus9033 closed 4 months ago

artus9033 commented 4 months ago

Summary

A problem used to occur on RN old architecture: when the native RNOmhMapsMarkerNativeComponent would have to be unmounted, the new RN architecture would first unmount its children (removeViewAt in RNOmhMapsCoreViewManager.kt) and then the map fragment, however the old architecture apparently would first unmount the fragment and then the children, causing us to call remove() from OmhMapEntity's unmountEntity on a non-existent map. This in turn would result in a NullPointerException.

This PR introduces a simple fix that makes RNOmhMapsCoreViewManagerImpl check if the map fragment is currently mounted in removeViewAt before performing any operations. This ensures proper behaviour on old RN architecture.

Demo

N/A

Checklist: