Hello,
I am building a project where I need to detect the right click on a certain component but I cannot use onClick since I’m not setting an event listener on the div but on the component itself(I cannot access its contents, it’s from npm)
Is there a way to attach some kind of an event listener to it?
I think it should be onContextMenu (or contextmenu in plain JS) but it doesn’t look like they support the event (Marker.js).
There might be some other way to do it, like a ref maybe, or using a listener higher up in the tree and then do some event delegation (both sounds potentially janky). Maybe look if a different lib supports the event.
What exactly is it you want to use the right-click for?
Thank you, I’ve tried with the second lib as well and indeed, there is onRightClick prop but when I try to look for the target of the event, it returns undefined so I can’t pick its id or other attributes so I’m stuck again
Edit: I figured out how to identify the marker I’m clicking on in the callback function, thank you so much for your time and effort!