useParentElement

Tags:

A React Hook that track the parent element of an element.

Demo

Source
Parent Element:
Parent #parent
Child #el-use-parent

Usage

See API for more details.

Source

Click links below to view source on GitHub.

API

const parentElement = useParentElement(elementTarget)

ElementTarget

ElementTarget is a union type that represents various kinds of elements that can be targeted.

See ElementTarget or ElementTarget Types for more details.

Returns

An HTMLElement or null.

export type UseParentElementReturns = HTMLElement | null