selectElementData()
function selectElementData<ElementData>(element): ElementData;
Selects an element's custom data payload, typed as ElementData. Supply
the type when you call it (selectElementData<NodeData>) and TypeScript
carries NodeData through to the value useCell returns.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
ElementData | unknown | shape of the custom data payload carried on the element |
Parameters
| Parameter | Type | Description |
|---|---|---|
element | Computed<ElementRecord<ElementData>> | the resolved element record |
Returns
ElementData
Example
import { useCell, selectElementData } from '@joint/react';
type NodeData = { label: string };
const data = useCell(elementId, selectElementData<NodeData>);