# use-child-nodes

### Modulo

```javascript
import { useChildNodes } from "@atomico/hooks/use-child-nodes";
```

### Syntax

```javascript
const [childNodes, update] = useChildNodes();
```

Where :

1. `childNodes` : List of nodes that do not belong to the webcomponent render.
2. `update`: Callback that forces a new `childNodes` scan.

### Example

```jsx
function component() {
  const [childNodes] = useChildNodes();
  return (
    <host>
      {childNodes
        .filter((node) => node.localName == "h1")
        .map((Title) => (
          <Title onclick={() => console.log("click h1!")} />
        ))}
    </host>
  );
}
```

From the example we can highlight that the webcomponent will use all the children not created by the `h1` type and will associate the onclick handler with them.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://atomico.gitbook.io/doc/packages/atomico-hooks/use-child-nodes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
