WarUI documentation

Immutable grid snapshots

experimental

Inspect versioned grid state and compare the references of each slice after a change.

Live example

Expected behavior

A committed change increments the version and preserves unrelated references. Direct mutation fails in development mode.

Source

import { createGrid } from '@warlockcode/warui-core';

const api = createGrid({
  rows: [{ price: 6 }, { price: 2 }],
  columns: [{ id: 'price', field: 'price' }],
});
const before = api.getState();
api.setSort([{ columnId: 'price', direction: 'asc' }]);
console.log(api.getState().columns === before.columns);

API reference

GRID-A01-F03 API
KindNameTypeDescription
MethodgetState() => GridState<TRow>Returns the last committed, structurally shared snapshot.
TypeGridState—Contains version, column definitions, sorting query, and selected row IDs.