JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin="" />
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
<button id="pm">new L.Map</button>
<div id="map" style="height:250px; width:550px;"></div>
To investiage https://github.com/Leaflet/Leaflet/issues/5774:
<ol>
<li>open JS console,</li>
<li>click <button id="rm">map.remove()</button>,</li>
<li>and see the leftover events in the console.</li>
</ol>
JavaScript
var map;
init();
function init() {
map = L.map('map').setView([51.505, -0.09], 3);
map.setMaxBounds([
[1, -10],
[60, 30]
]);
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);
}
function remove() {
map.remove();
console.log('leftover events', map._events);
}
document.getElementById('pm').onclick = init;
document.getElementById('rm').onclick = remove;