title: Deleting current layer when a new layer is created with react-leaflet-draw version 0.19.8 in leaflet version 1.7.1 and react-leaflet version 2.8.3
body: <p>I used the solution in this question (<a href="https://stackoverflow.com/questions/61073568/delete-layer-before-creating-a-new-one-with-react-leaflet-draw-in-leaflet">Delete layer before creating a new one with react-leaflet-draw in leaflet</a>) to gain ability to draw only one shape(layer) in React and Typescript map project, but I got <code>cannot read propery leafletElement of undefined</code>, I used leaflet v1.7.1, leaflet-draw 1.0.4, React-leaflet v2.8.3 and React-leaflet-draw v0.19.8, I guess leafletElement is replaced with something alternative in new versions. How can I implement deleting layers when new shape is created in versions above?</p>
  <p>Note1: I used <code>&lt;MapContainer/&gt;</code> component in React-leaflet v2.8.3 which is alternative to <code>&lt;Map /&gt;</code> component in React-leaflet v2.6.0</p>
  <p>Note2: I can't figure out what is type of <code>editableFG</code> and <code>e</code> (in onCreated eventHandler) and <code>reactFGref</code> in leaflet core API so I used <code>any</code></p>
  <p>Here is my code:</p>
  <pre><code>const [editableFG, setEditableFG] = useState&lt;any&gt;(null);
  
  const onCreated = (e: any) =&gt; {
    const drawnItems = editableFG.leafletElement._layers;
    if (Object.keys(drawnItems).length &gt; 1) {
      Object.keys(drawnItems).forEach((layerid, index) =&gt; {
      if (index &gt; 0) {
        return;
      }
        const layer = drawnItems[layerid];
        editableFG.leafletElement.removeLayer(layer);
      });
    }
  };
  
  const onFeatureGroupReady = (reactFGref: any) =&gt; {
    setEditableFG(reactFGref);
  };
  
  return (
    &lt;MapContainer
      center={center}
      zoom={zoom}
      className={classes.mapContainer}
    &gt;
      &lt;TileLayer
        attribution='&amp;copy; &lt;a href=&quot;http://osm.org/copyright&quot;&gt;OpenStreetMap&lt;/a&gt; contributors'
        url=&quot;http://{s}.tile.osm.org/{z}/{x}/{y}.png&quot;
      /&gt;
      &lt;FeatureGroup
        ref={
          (featureGroupRef: any) =&gt; {
            onFeatureGroupReady(featureGroupRef);
          }
        }
      &gt;
        &lt;EditControl
          position=&quot;topright&quot; 
          onCreated={onCreated}
          draw={{
            rectangle: false,
            circleMarker: false,
            marker: false,
            circle: true,
            polyline: true,
            polygon: true
          }}
        /&gt;
      &lt;/FeatureGroup&gt;
    &lt;/Map&gt;
  );
  </code></pre>