Subscribe to a collection's cells. Tracks collection membership
(add/remove/reset) and reads cell records from the GraphProvider's
container. Cells not in the graph (e.g. ui.Clipboard clones) fall back to
the collection's own dia.Cell instances, converted to records on demand.
resolved cell record shape (defaults to Computed
JointJS collection whose member IDs drive the subscription
readonly resolved cells array filtered by collection membership
Subscribe to a collection's cells with a selector.
resolved cell record shape (defaults to Computed
selector return type
JointJS collection whose member IDs drive the subscription
derive a value from the picked resolved cells array
OptionalisEqual: (a: Selected, b: Selected) => booleanequality test used to short-circuit re-renders (defaults to a shallow, array-aware comparison that falls back to Object.is for scalar results)
selected value
Subscribe to the full cells array.
Returned array reference is stable across data-only mutations (the internal container mutates items in-place). Size changes produce a new snapshot token.
resolved cell record shape (defaults to Computed
readonly resolved cells array
Subscribe to a single cell by id.
resolved cell record shape (defaults to Computed
cell id to track
current resolved cell, or undefined when missing
Subscribe to a single cell by id and derive a value from it. Subscribes
only to that id so unrelated mutations don't trigger re-renders. A nullish
id resolves to no cell, so the selector runs against undefined, handy
for optional selection state (useCells(selectedId, ...)) with no ?? ''.
resolved cell record shape (defaults to Computed
selector return type (defaults to Cell | undefined)
cell id to track (nullish → selector receives undefined)
derive a value from the cell (or undefined when missing)
OptionalisEqual: (a: Selected, b: Selected) => booleanequality test used to short-circuit re-renders (defaults to a shallow, array-aware comparison that falls back to Object.is for scalar results)
selected value
Subscribe to a specific set of cells by id. Subscribes only to those ids
(not the full container) so unrelated mutations don't trigger re-renders.
Returns the picked cells in the order they appear in ids; missing ids
are skipped. The array reference is stable when no picked cell changed.
resolved cell record shape (defaults to Computed
cell ids to track
array of resolved cells (only those that exist; missing ids are skipped)
Subscribe to a specific set of cells by id and derive a value from them. Subscribes only to those ids; the selector receives the picked cells array.
resolved cell record shape (defaults to Computed
selector return type (defaults to readonly Cell[])
cell ids to track
derive a value from the picked resolved cells array
OptionalisEqual: (a: Selected, b: Selected) => booleanequality test used to short-circuit re-renders (defaults to a shallow, array-aware comparison that falls back to Object.is for scalar results)
selected value
Subscribe via a selector. Runs on every commit; return equal values to skip re-render.
resolved cell record shape (defaults to Computed
selector return type (defaults to readonly Cell[])
selected value
import { useCells } from '@joint/react';
function ElementCount() {
// Counts cells whose type is the default 'element' and re-renders only when
// that count changes; shape-typed elements (e.g. 'standard.Rectangle') are
// not included.
const count = useCells((cells) => cells.filter((cell) => cell.type === 'element').length);
return <span>{count} elements</span>;
}
useCells()