onDragStart now fires after 3px of mouse movement, not on mousedown. This fixes #1341 and #1401. Use onMouseDown directly on grid items if you need immediate response.
Immutable Callback Parameters
Callback parameters (layoutItem, placeholder) are now read-only. Mutating them in onResize/onDrag callbacks no longer works. Use onLayoutChange or item constraints (minW, maxW, etc.) instead.
data-grid Prop in Legacy Only
The v2 API requires explicit layout prop. The data-grid pattern is only available via the legacy wrapper (react-grid-layout/legacy).
Pluggable Compaction Algorithms
Compaction is now pluggable via the Compactor interface. The default compaction algorithm remains the same as v1 for backwards compatibility. For large layouts (200+ items), an optional O(n log n) fast compactor is available in react-grid-layout/extras:
import { fastVerticalCompactor } from 'react-grid-layout/extras';
<GridLayout compactor={fastVerticalCompactor} />
Other Breaking Changes
UMD bundle removed - Use a bundler (Vite, webpack, esbuild)
verticalCompact prop removed - Use compactType={null} or compactor={noCompactor}
React 18+ required - React 16/17 support is available only via the legacy wrapper
๐ New Features
Entry Points
// v2 API (recommended)
import ReactGridLayout, {
Responsive,
useContainerWidth
} from "react-grid-layout";
// Core utilities (framework-agnostic, no React)
import { compact, moveElement, collides } from "react-grid-layout/core";
// Legacy v1 API (100% backwards compatible)
import ReactGridLayout, {
WidthProvider,
Responsive
} from "react-grid-layout/legacy";
// Optional extras
import { GridBackground, fastVerticalCompactor } from "react-grid-layout/extras";
Hooks
useContainerWidth() - Reactive container width measurement with ResizeObserver
useGridLayout() - Core layout state management for custom implementations