mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* Add types for react-shadow-dom-retarget-events * Use esModuleInterop for react-shadow-dom-retarget-events
23 lines
659 B
TypeScript
23 lines
659 B
TypeScript
import * as React from 'react';
|
|
import * as ReactDOM from 'react-dom';
|
|
import retargetEvents from 'react-shadow-dom-retarget-events';
|
|
|
|
class App extends React.Component {
|
|
render() {
|
|
return <div onClick={() => alert('I have been clicked')}>Click me</div>;
|
|
}
|
|
}
|
|
|
|
class MyCustomElement extends HTMLElement {
|
|
constructor() {
|
|
super();
|
|
const mountPoint = document.createElement('span');
|
|
const shadowRoot = this.attachShadow({ mode: 'open' });
|
|
shadowRoot.appendChild(mountPoint);
|
|
ReactDOM.render(<App/>, mountPoint);
|
|
retargetEvents(shadowRoot);
|
|
}
|
|
}
|
|
|
|
customElements.define(name, MyCustomElement);
|