use-parent

Retrieve a node higher than the current webcomponent.

Module

import { useParent, useParentPath } from "@atomico/hooks/use-parent";

Syntax useParent

const selector = "form";
const parent = useParent(selector);

Where:

  • selector: String, Selector to be used by Element.matches when searching for the parent.

  • parent: Element, ascending search result according to selector.

Syntax useParentPath

const parents = useParentPath(composed?: boolean);

Where:

  • parents: parent nodes of the webcomponent

  • composed: bypasses shadow DOM in parent capture.

Example

Last updated