Skip to content

Instantly share code, notes, and snippets.

@realiarthur
Created March 13, 2023 11:59
Show Gist options
  • Save realiarthur/b429ccee1fa08f35dbd15e78580510ef to your computer and use it in GitHub Desktop.
Save realiarthur/b429ccee1fa08f35dbd15e78580510ef to your computer and use it in GitHub Desktop.
import { useEffect, useRef } from 'react'
import { render } from 'lit-html'
export const RenderLit = ({ html }) => {
const container = useRef(null)
useEffect(() => {
const element = container.current
if (element) {
render(html, element)
}
}, [html])
return <div ref={container}></div>
}
const Usage = () => {
const boolean = true
const callback = ()=>{}
return <RenderLit
html={html`<my-web-component
?boolean=${boolean}
.callback=${callback}
></set-password-input>`}
/>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment