Documentation

@kanunilabs/pivotgrid-react


@kanunilabs/pivotgrid-react / usePivotController

Function: usePivotController()

usePivotController<TRow>(options, attachedTo?): PivotController<TRow>

The grid's controller, kept for the life of the component (per gridId).

B.108: React runs the same effect cleanup when <Activity mode="hidden"> hides the grid as when it unmounts it; what differs is the DOM. An unmount removes the grid's element in the commit, before the cleanups; a hide keeps it (display: none). So, with attachedTo (the grid's element, captured at setup — React detaches refs on hide):

  • element gone → dispose(), as before B.108;
  • element still there → suspend() after 0 ms (StrictMode's cleanup + setup in one task cancels it), and a check every 5 s disposes it after two misses in a row (a grid unmounted while hidden gets no second cleanup). The setup resume()s. A controller found disposed there (a host that took the hidden element out of the page, an app's own dispose()) is replaced by a fresh one with the old one's layout state: a reset, never a dead grid. The engine starts on the first resume() (start: 'resume'), so a controller React throws away never claims a worker. Without attachedTo the cleanup only suspends.

Type Parameters

TRow

TRow

Parameters

options

PivotControllerOptions<TRow>

attachedTo?

RefObject<Element | null>

Returns

PivotController<TRow>