arcgis-maps-sdk-kotlin-samples icon indicating copy to clipboard operation
arcgis-maps-sdk-kotlin-samples copied to clipboard

When reusing composable - error ObjectAlreadyOwnedException

Open eugene-rsi-europe opened this issue 1 year ago • 0 comments

https://github.com/Esri/arcgis-maps-sdk-kotlin-samples/blob/6008ed17ec1e357fbc6f80b80b46452afd401163/show-callout/src/main/java/com/esri/arcgismaps/sample/showcallout/components/ComposeMapView.kt#L97

change this

DisposableEffect(lifecycleOwner) {
        lifecycleOwner.lifecycle.addObserver(mapView)
        onDispose {
            lifecycleOwner.lifecycle.removeObserver(mapView)
        }
    }

To this

DisposableEffect(lifecycleOwner) {
        lifecycleOwner.lifecycle.addObserver(mapView)
        onDispose {
            lifecycleOwner.lifecycle.removeObserver(mapView)
            mapView.map = null
        }
    }

eugene-rsi-europe avatar May 28 '24 08:05 eugene-rsi-europe