Skip to main content
Version: 4.3

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 ParameterDefault typeDescription
ElementDataunknownshape of the custom data payload carried on the element

Parameters

ParameterTypeDescription
elementComputed<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>);

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub