Fixing unmounting of layers during runtime (v10, iOS)#1843
Fixing unmounting of layers during runtime (v10, iOS)#1843mfazekas merged 1 commit intornmapbox:mainfrom
Conversation
ca43483 to
11bfcf8
Compare
mfazekas
left a comment
There was a problem hiding this comment.
@rastapasta can you add a short sample code, where the issue occurs.
I assume something like this, and when setting visible to false the component still rendered on the map?!
<MapView>
{visible && <ShapeSource>
<CircleLayer .../>
</ShapeSource>
}
</MapView>
| sources.append(source) | ||
| } | ||
|
|
||
| super.insertReactSubview(subview, at: atIndex) |
There was a problem hiding this comment.
Interesting that we haven't called insertReactSubview in prev implementation but we did overwrote reactSubviews.
Not sure if it worth the trouble to not do the pre v10 implementation, calling super.insertReactSubview sounds simpler.
See
maps/ios/RCTMGL/RCTMGLMapView.m
Lines 217 to 220 in f42cacc
There was a problem hiding this comment.
Found that interesting as well when digging through the code to explain its behavior, though found no advantage of re-implementing the reactSubviews as done previously.
There was a problem hiding this comment.
@mfazekas your guess was spot on! added an example to the PR description.
There was a problem hiding this comment.
The only difference I can think of is that views were not added, to MapView before.
So this
<MapVIew>
<View style={{backgroundColor: 'red', width: 100, height: 100}} />
</MapView>
will now add a view into MapView, not sure if that's works on android.
Let's go with this implementation for now, we can revisit later.
Description
In the new swift implementation, the MapView's removeReactSubview is never called by the RTCManager, resulting in removed React Components not being unmounted from the map.
To solve this, the corresponding super methods are called resulting in the removeReactSubview method being called and layers removed from the map.
Checklist
yarn lint:fixin the root folderyarn generatein the root folderCHANGELOG.mdindex.d.ts)/example)Example code