'Is there a way to obtain layer name from onEachFeature on react leaflet?

I have tried to found something inside feature and layer methods and properties (these are the params onEachFeature returns) but the documentation doesn´t say how to achieve this.

I have multiple layers, and once I click on one feature, I want my popup to be able to identify which layer it belongs to.

const onEachFeature = (feature, layer) => {
  const popupContent = ReactDOMServer.renderToString(
    layer  <-how to get layer properties from this like layer name?
    <Custompopup feature={feature} />
  );
  layer.bindPopup(popupContent);
};```




Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source