Click event not firing when React Component in a Shadow DOM

前端 未结 4 1432
耶瑟儿~
耶瑟儿~ 2020-12-08 10:23

I have a special case where I need to encapsulate a React Component with a Web Component. The setup seems very straight forward. Here is the React Code:

//         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 11:04

    Replacing this.el = this.createShadowRoot(); with this.el = document.getElementById("mountReact"); just worked. Maybe because react has a global event handler and shadow dom implies event retargeting.

提交回复
热议问题