title: Leaflet-React : L is not defined
body: <p>I have been using leaflet to allow geo-results to render onto a map for users to see where their results are located. This has worked fine up until now because I have been using the base functionality of the map.</p>
  <pre><code>import React from &quot;react&quot;;
  import { Map, Marker, Popup, TileLayer } from &quot;react-leaflet&quot;;
  
  
     const MapComp = (props) =&gt; {
  
          return (
              &lt;div id='map'&gt;
                  &lt;Map center={[0, 0]} zoom={0}&gt;
                      &lt;TileLayer
                          url=&quot;https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png&quot;
                          attribution='&amp;copy; &lt;a href=&quot;http://osm.org/copyright&quot;&gt;OpenStreetMap&lt;/a&gt; contributors'
                      /&gt;
                      {
                          props.locations.map(marker =&gt; (
                          &lt;Marker
                              key={marker.props.id}
                              position={ [
                                  marker.lat,
                                  marker.long
                              ]}
                              
                          &gt;
                              &lt;Popup&gt;
                                  &lt;b&gt;Media ID:&lt;/b&gt; {marker.props.values.mediaId}
                                  &lt;br/&gt;
                                  &lt;b&gt;Created Date:&lt;/b&gt; {marker.props.values.createdDate}
                                  &lt;br/&gt;
                                  &lt;b&gt;Media URL:&lt;/b&gt; &lt;button onClick={()=&gt; window.open(marker.props.values.mediaURL)}&gt;Link&lt;/button&gt;
                              &lt;/Popup&gt;
                          &lt;/Marker&gt;
                      ))}
                  &lt;/Map&gt;
              &lt;/div&gt;
          );
  
  };
  
  export default MapComp;
  </code></pre>
  <p>The error &quot;L is not defined&quot; appears when I attempt to implement <em>leaflet-draw</em>. In order to do this, I need to create a feature group of drawnItems. To do this, I need to use <code>L.FeatureGroup()</code>. For simplicity, I can demonstrate how just one line will cause the app to not compile.</p>
  <pre><code>const drawnItems = new L.FeatureGroup();
  </code></pre>
  <p><a href="https://i.stack.imgur.com/IGEcG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IGEcG.png" alt="Compilation Error" /></a></p>
  <p>The index.html is as follows:</p>
  <pre><code>    &lt;!DOCTYPE html&gt;
  </code></pre>
  
    
      
      
     
      
  <pre><code>&lt;link rel=&quot;stylesheet&quot; href=&quot;https://unpkg.com/leaflet@1.7.1/dist/leaflet.css&quot;
        integrity=&quot;sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==&quot;
        crossorigin=&quot;&quot;/&gt;
  &lt;script src=&quot;https://unpkg.com/leaflet@1.7.1/dist/leaflet.js&quot;
          integrity=&quot;sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==&quot;
          crossorigin=&quot;&quot;&gt;&lt;/script&gt;
  
  &lt;title&gt;React App&lt;/title&gt;
  </code></pre>
    
  <p>Along with the leaflet-map css:</p>
  <pre><code>.leaflet-container {
  width: 90%;
  height: 75vh;
  border-radius: 20px;
  margin-left: 0px;
  margin-top: 10px;
  </code></pre>
  <p>}</p>
  <p>I have attempted to source the leaflet library locally by putting it into the project directory but this only caused more issues with leaflets styling, it clearly was an issue on my end but after some investigation to other stack overflow questions, I saw other people having the same troubles regardless of how they accessed the leaflet library.  I have followed all steps on the leaflet <a href="https://leafletjs.com/examples/quick-start/" rel="nofollow noreferrer">quick start</a> guide, to no avail.</p>
  <p>Any help would be appreciated!</p>
  <p>Thanks.</p>