UNPKG

react-responsive-pagination

Version:
12 lines (11 loc) 432 B
import { useState } from 'react'; import { useContentWidth } from "./useContentWidth.js"; export function useAvailableWidth(overrideWidth) { const [element, setElement] = useState(null); const parentElement = element?.parentElement ?? undefined; const width = useContentWidth(overrideWidth === undefined ? parentElement : undefined); return { width: overrideWidth ?? width, ref: setElement, }; }