Skip to main content

getState

Returns a plain object with the current values of all store fields. The snapshot isn't reactive - reading it inside a reactive context won't trigger updates. Use getReactiveState() when you need live subscriptions.

Usage

getState(): State
FieldTypeDescription
cardsCardsStoreInternal card storage with CRUD methods
columnsColumnConfig[]Column definitions in board order
columnAccessorColumnAccessorResolver for card-to-column membership
filtersMap<string, FilterPredicate>Active filter predicates keyed by tag
sortSortCriterionActive sort criterion, or null
editorDataKanbanCard | nullCurrently selected card, or null
dynamicDatabooleanWhether dynamic loading is enabled
columnDataMap<ColumnID, { status: ColumnDataStatus }>Per-column load state ("unknown", "loading", "loaded")
history{ undo: number; redo: number }Available undo/redo step counts
viewDataKanbanModelProjected render model (filtered, sorted columns with cards)

Example

import { useRef } from "react";
import { Kanban } from "@svar-ui/react-kanban";

function App() {
const apiRef = useRef(null);

function logState() {
const state = apiRef.current.getState();
console.log("columns:", state.columns);
console.log("selected card:", state.editorData);
}

return (
<>
<Kanban cards={cards} columns={columns} ref={apiRef} />
<button onClick={logState}>Log state</button>
</>
);
}