After updating from 2.6.1 to 2.6.3 I got "TypeError: Cannot read property 'addLayer' of undefined" error
All components (leaflet, react, etc) are latest.
Call stack displays:
-
setState([my variables for map content like markers, etc.])
-
[internal react calls]
-
Fall in MapLayer.js:40 at line this.layerContainer.addLayer(this.leafletElement);
When I downgrade back to to 2.6.1, everything works fine.
Don't know what else I can add to description. Project is huge enought and I cannot extract minimal code to reproduce.
Please provide a simple example to reproduce the issue, this is not enough information to investigate.
I think I narrowed down the problem. Look like changes between 2.6.1 and 2.6.3 are incompatible with react-leaflet-google-v2 module (https://github.com/TA-Geoforce/react-leaflet-google-v2) used to display Google maps.
The following works in both 2.6.1 and 2.6.3:
<Map
center={[this.state.lat, this.state.lng]}
zoom={this.state.zoom}
>
<TileLayer
attribution='© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
url='http://{s}.tile.osm.org/{z}/{x}/{y}.png'
/>
</Map>
The following works in 2.6.1, but doesn't work in 2.6.3:
<Map
center={[this.state.lat, this.state.lng]}
zoom={this.state.zoom}
>
<GoogleLayer maptype="ROADMAP" googlekey="<key>"/>
</Map>
I don't know is it a problem with react-leaflet or react-leaflet-google-v2, but I hope you might know it better.
I would very happy if you could make a fix to support react-leaflet-google-v2 like in 2.6.1.
Thanks for the details. It seems to be an issue with react-leaflet-google-v2 then, that should be raised in their repository rather than here.
Please feel free to reopen the issue if you can reproduce it with only the components provided by react-leaflet.
I am seeing the same issue on 2.6.3, except I am using only react-leaflet to create a customComponent. It appears that the LayersControl.Overlay is not receiving the inherited props from LayersControl-
<LayersControl.Overlay checked={showOnLoad} name={layerName}>
<FeatureGroup ref={groupRef}>
...implementation...
</FeatureGroup>
</LayersControl.Overlay>
);
which yields this -

You can see on line 16182 that addLayer is undefined on the object returned from ControlledLayer. Somehow the inherited class is not being applied?
I don't have easy access to data, which makes this webpack debugging a bit dicey. If you have ideas of why this might be happening, would be happy to investigate further.