I am trying to update my WMS layer on react-leaflet v2.x.x. The WMSTileLayer works only with the first layer and when I change the layers parameter on it, it shows the previously added layer. I have written following code,
<MapContainer
whenCreated={(mapInstance) => {
mapRef.current = mapInstance;
}}
center={[38.861, 71.2761]}
zoom={5}
zoomControl={false}
style={{ width: "100%", height: "70vh" }}
>
<ZoomControl position="topright" />
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution="© <a href='https://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors"
/>
<WMSTileLayer
layers={this.props.wmsLayer}
url={`${process.env.REACT_APP_GEOSERVER_URL}/wms`}
transparent={true}
format={"image/png"}
/>
</MapContainer>
So my question is, how to update the WMSTileLayer when my this.props.wmsLayer is updated?