Changelog - 2026-11-04
useSizer is removed, use useElementSize
Breaking ChangeIn one line. useSizer({ containerId }) is removed from @venizia/ardor-react, @venizia/ardor and the Ardor namespace. useElementSize does the same job for a ref, with a box, round and a measured flag, so ARDOR keeps one hook for one concept. There is no alias.
tsx
import React from 'react';
import { useElementSize } from '@venizia/ardor';
export function ChartContainer() {
const ref = React.useRef<HTMLDivElement>(null);
const { width, height } = useElementSize({ ref, box: 'border-box', round: true });
return (
<div ref={ref}>
<span>
Width: {width}, Height: {height}
</span>
</div>
);
}What changed
useSizeris gone, with itsIUseSizerOptionsandIUseSizerReturntypes, its entry inArdor(which now holds 30 hooks) and its entry in the codemod's hook table.- The replacement is
useElementSize({ ref, box: 'border-box', round: true }). It is close to whatuseSizerread (offsetWidthandoffsetHeight), not the same: the value is the border box rounded withMath.round, which can differ by 1 px from the browser's own snapping ofoffsetWidth; it updates once per animation frame, so one frame later thanuseSizerdid; and in a browser withoutborderBoxSizeit falls back to the content box. It takes arefobject instead of an element id. - One more field.
useSizergave0by0until the element existed;useElementSizealso returnsmeasured,falseuntil the first size is read, so you can tell an unmeasured element from an empty one.
Upgrade
diff
-const { width, height } = useSizer({ containerId: 'chart' });
+const ref = React.useRef<HTMLDivElement>(null);
+const { width, height } = useElementSize({ ref, box: 'border-box', round: true });Give the element the ref in place of the id.
Who is affected
- An app that calls
useSizer. Move it touseElementSizeas above: give the element arefand pass it, in place of theid. - All other apps. No action needed.
See Hooks.