Open timonkuiters opened 3 weeks ago
Assuming it works to keep the map active while detaching its anchor element from the DOM, there's still a lot of complexity involved here. Every component inside the map would have to reconcile with the existing state in the map as well as adding sources/layers that need to exist, and removing those which are left over from the previous instantiation.
I'm not totally opposed to such a feature but it's a big effort to actually get this working properly. I think it would probably work better to have some solution that can just hide the map component, instead of tearing it down.
If a map unmounts and mounts multiple times, it is re-initialised every time, which you can see visually. A reuseId prop could perhaps identify the map instance, so it could be saved when unmounted, and re-used when re-mounted.