Created
February 28, 2020 01:56
-
-
Save alexgwolff/b4fa95abfdcbbd82fe6ebffbe0df0ad5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ShadowRoot = ({ content, children }) => { | |
const container = useRef(null); | |
useEffect(() => { | |
if (container) { | |
const shadowRoot = container.current.attachShadow({ mode: 'open' }); | |
ReactDOM.render(children, shadowRoot); | |
} | |
}, []); | |
return ( | |
<div style={{ height: '100%', width: '100%' }} ref={container}> | |
{content} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment