Skip to content

Instantly share code, notes, and snippets.

@alexgwolff
Created February 28, 2020 01:56
Show Gist options
  • Save alexgwolff/b4fa95abfdcbbd82fe6ebffbe0df0ad5 to your computer and use it in GitHub Desktop.
Save alexgwolff/b4fa95abfdcbbd82fe6ebffbe0df0ad5 to your computer and use it in GitHub Desktop.
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