use-parent
Retrieve a node higher than the current webcomponent.

Module

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

Syntax useParent

1
const selector = "form";
2
const parent = useParent(selector);
Copied!
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

1
const parents = useParentPath(composed?: boolean);
Copied!
Where:
  • parents: parent nodes of the webcomponent
  • composed: bypasses shadow DOM in parent capture.

Example

WebComponents.dev
WebComponents.dev