Problem
useResizable defaults snaps with an array literal during render:
const {snaps = []} = config;
When callers omit snaps, that produces a new array on every render. Because expand, resize, and onResizeMove depend on snaps, those callbacks are recreated too. The private _snaps value passed to ResizeHandle also changes identity even though the configuration did not change.
Proposed fix
Keep one empty snaps array per hook instance with useRef, and use it only when config.snaps is absent. Explicit caller-provided arrays keep their existing behavior.
Regression coverage
A hook test rerenders the same omitted-snaps configuration and verifies that:
expand remains stable
resize remains stable
props._snaps remains stable
The test fails on current main and passes with the patch. Existing ResizeHandle behavior remains green.
This change intentionally does not memoize the entire useResizable return object; that broader optimization is not needed to fix the confirmed default-array defect.
Problem
useResizabledefaultssnapswith an array literal during render:When callers omit
snaps, that produces a new array on every render. Becauseexpand,resize, andonResizeMovedepend onsnaps, those callbacks are recreated too. The private_snapsvalue passed toResizeHandlealso changes identity even though the configuration did not change.Proposed fix
Keep one empty snaps array per hook instance with
useRef, and use it only whenconfig.snapsis absent. Explicit caller-provided arrays keep their existing behavior.Regression coverage
A hook test rerenders the same omitted-snaps configuration and verifies that:
expandremains stableresizeremains stableprops._snapsremains stableThe test fails on current main and passes with the patch. Existing ResizeHandle behavior remains green.
This change intentionally does not memoize the entire
useResizablereturn object; that broader optimization is not needed to fix the confirmed default-array defect.