UPDATE: I see this was actually fix as suggested below, it just hasn't been released on npm - so no need to comment
I've just started using L.mapboxGL to create a instead of a in my map. Everything's rendering beautifully, but I'm httting issues when the map component unmounts - meaning it must be working differently from TileLayer (which never caused unmount issues). Some of the debug info:
TypeError: obj is undefined
removeOne leaflet-src.js:2702
off leaflet-src.js:2635
onRemove leaflet-mapbox-gl.js:75
removeLayer leaflet-src.js:6606
removeFrom leaflet-src.js:6487
remove leaflet-src.js:6480
remove leaflet-src.js:3738
componentWillUnmount: React
I don't understand the code well enough to fix - but it seems leaflet-mapbox-gl.js "onRemove" function is passing null references to "off" and "removeOne" for leaflet-src.js, resulting in a crash.
If I wrap the L.DomEvent.off call as follows, my code works correctly as before:
if (this._map._proxy) {
L.DomEvent.off(
this._map._proxy,
L.DomUtil.TRANSITION_END,
this._transitionEnd,
this
);
}
(but I doubt this is the correct fix as it's just a quick null check)
I would be happy to share any more info that could help
UPDATE: I see this was actually fix as suggested below, it just hasn't been released on npm - so no need to comment
I've just started using L.mapboxGL to create a instead of a in my map. Everything's rendering beautifully, but I'm httting issues when the map component unmounts - meaning it must be working differently from TileLayer (which never caused unmount issues). Some of the debug info:
I don't understand the code well enough to fix - but it seems leaflet-mapbox-gl.js "onRemove" function is passing null references to "off" and "removeOne" for leaflet-src.js, resulting in a crash.
If I wrap the L.DomEvent.off call as follows, my code works correctly as before:
(but I doubt this is the correct fix as it's just a quick null check)
I would be happy to share any more info that could help