Skip to main content
Version: 4.3

useCellId()

function useCellId(): ID;

Read the current cell id from the nearest CellIdContext. Populated by <Paper /> around every renderElement / renderLink invocation.

Use this inside a render callback (or any component mounted from one) when you only need the id, it's cheaper than useCell() since it never subscribes to store updates. Throws when used outside a Paper render context.

Returns​

ID

the current cell id

Example​

import { useCellId } from '@joint/react';

function MyElement() {
const id = useCellId();
return <text>{id}</text>;
}

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub