Skip to content

unrefElement

Category
Export Size
119 B
Last Changed
5 days ago

Get the DOM element a React ref object currently holds

Demo

Usage

tsx
import { 
unrefElement
} from '@reause/core'
import {
useEffect
,
useRef
} from 'react'
const
div
=
useRef
<HTMLDivElement>(null)
useEffect
(() => {
console
.
log
(
unrefElement
(
div
)) // the <div> element (div.current)
})

Type Declarations

ts
export type UnRefElementReturn<T> = T | undefined

export function unrefElement<T>(elRef: RefObject<T | null | undefined>): UnRefElementReturn<T>

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
ebeb0 - fix(core): resolve unrefElement audit findings (#515)
5451e - feat(core): add unrefElement (#60)

Released under the MIT License. v0.1.8