MCPcopy
hub / github.com/react-grid-layout/react-grid-layout / withLayoutItem

Function withLayoutItem

src/core/layout.ts:163–178  ·  view source on GitHub ↗
(
  layout: Layout,
  itemKey: string,
  cb: (item: LayoutItem) => LayoutItem
)

Source from the content-addressed store, hash-verified

161 * @returns Tuple of [new layout, modified item or null if not found]
162 */
163export function withLayoutItem(
164 layout: Layout,
165 itemKey: string,
166 cb: (item: LayoutItem) => LayoutItem
167): [LayoutItem[], LayoutItem | null] {
168 let item = getLayoutItem(layout, itemKey);
169 if (!item) {
170 return [[...layout], null];
171 }
172
173 // Clone, then modify via callback
174 item = cb(cloneLayoutItem(item));
175 const newLayout = modifyLayout(layout, item);
176
177 return [newLayout, item];
178}
179
180// ============================================================================
181// Bounds Correction

Callers 1

GridLayoutFunction · 0.85

Calls 3

getLayoutItemFunction · 0.85
cloneLayoutItemFunction · 0.85
modifyLayoutFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…