react-leaflet
react-leaflet copied to clipboard
Dynamic Button with onClick in Popup
How can I put a dynamic button in my Popup, when clicked it should fire a react function?
Something like (where I have someCustomReactFunction):
onEachFeature: (feature = {}, layer) => {
const popup = L.popup();
const html = `
<div class="user-popup">
<button onClick=${someCustomReactFunction}>View</button>
</div>
`;
popup.setContent(html)
layer.bindPopup(popup);
}
onClick={someCustomReactFunction} is how you do it. If I understood the question.