I am working on adding React components to an existing project with lots of legacy code.
One problem I am facing is that React attaches handlers to delegate events to the document object. Unfortunately, for me, a lot of our legacy code intercepts click events and calls event.stopPropagation before they get into the document object (for example, to process drop-down lists and modals that close when you go beyond them).
When a click event is intercepted, the event does not extend to the React document-level event handler, and the event is not dispatched to my React components (even if the actual DOM elements for the components are located above the intercepted element in the DOM and receive the actual, non-delegated events first).
So ... question: is there a way to manually trigger a synthetic React event for a given event without hitting it. React document-level event handler? Or is there a way to move or duplicate this single event handler somewhere else?
As a backup, I am considering using jQuery to add events after mounting React components, but I would prefer not to, if possible.
source share