DefinitelyTyped/types/react-shadow-dom-retarget-events/react-shadow-dom-retarget-events-tests.tsx
Remco Haszing b3a144d609 Add types for react-shadow-dom-retarget-events (#35200)
* Add types for react-shadow-dom-retarget-events

* Use esModuleInterop for react-shadow-dom-retarget-events
2019-05-28 12:40:26 -07:00

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);