Reactjs event handler not triggered for element in a container which prevent event bubbling -
i'm using react map library, use react render elements in container provided map library.
the problem container prevent event bubbling, checkout reactjs source code found event emitter listen on html document , depend on event bubbling dispatch event.
how can make onclick handler work? addeventlistener manually don't think elegant way.
<body> <container preventbubbling> <reactelement onclick={this.handleclick}/> </container> </body>
as said, react depends on event bubbling instead of attaching event handlers directly dom node want events for. integral part of react, , not can avoid without manually attaching event handlers in componentdidmount
. , manually removing them in componentwillunmount
.
what's reason cancelling bubbling in map library? i'd try remove cancellation , see if works.