I'm using React Leaflet's components to compose a list of dynamically added data layers as follows, which nicely adds that layer to the LayersControl that's wrapping it all.
<LayersControl.Overlay checked name={layer.name}>
<GeoJSON
data={layer.data}
onEachFeature={(feature, localLayer) => {
localLayer.on({
click: event => onFeatureSelect(event, feature),
})
}}
style={getStyle}
type={layer.type}
/>
</LayersControl.Overlay>
I now would like to add additional functionality for every layer, like filtering based on user input (e.g. only show features that match this and that). Therefore I am looking for a way to bind an onClick to the list of layers in the LayersControl. An alternative would be to fully customize the LayersControl, something that seems to be way too verbose for my need. onClick doesn't work, nor can I get a list of all my overlays programmatically to do what I want.
If I drop the React Leaflet way of doing it, meaning creating those layers programmatically, it seems rather simple. But I appreciate the simplicity and readability of code produced with that library and would like to find a way. Can anybody point me at a solution, any feedback is appreciated.
P.S. HNY!!!