UNPKG

@figliolia/react-hooks

Version:

A small collection of simple React Hooks you're probably rewriting on a regular basis

14 lines (13 loc) 417 B
import { useMemo, useState } from "react"; import { useSizeObserver, } from "@figliolia/size-observer"; export const useNodeDimensions = () => { const [dimensions, onChange] = useState(undefined); const options = useMemo(() => ({ onChange, width: true, height: true, type: "border-box", }), []); const node = useSizeObserver(options); return [node, dimensions]; };