use-child-nodes
Captures all nodes not created by the webcomponent render, ideal for apply slot polyfill in LightDOM.
Modulo
import { useChildNodes } from "@atomico/hooks/use-child-nodes";Syntax
const [childNodes, update] = useChildNodes();Example
function component() {
const [childNodes] = useChildNodes();
return (
<host>
{childNodes
.filter((node) => node.localName == "h1")
.map((Title) => (
<Title onclick={() => console.log("click h1!")} />
))}
</host>
);
}Last updated
Was this helpful?
