I have a 'leaflet-react' map, with some markers. When a marker is clicked, a popup opens. When you click away or close the popup, I need to know when is's closed so I can tell if it's open.
the marker generation looks like the code below. Marker and Popup come from 'react-leaflet', SiteForm is my code.
var markers = this.props.sites.map((item, i) => {
<Marker icon={icon} key={i} position={{ lng: co[0], lat: co[1] }}>
<Popup>
<SiteForm item={item} />
</Popup>
</Marker>
}
in componentDidMount in Siteform I can tell when a popup is opened, but componentWillUnmount isn't triggered when you close the popup.
I've tried extending Marker, but thats bad practise and also I couldn't extend from the Marker Symbol. I've also tried wrapping Popup in a component but componentDidMount runs on every marker when the page loads not popup open.
onClose: () => void
to your popup or marker – FortyTwo