nodeKey

Returns a stable key for a node among its siblings: its instance_id, or the fallback when it has none.

@internote/canvas-sdkFunction
On this page
import { nodeKey } from '@internote/canvas-sdk';

A node synthesised at render time, or one built in a test, has no instance id, which is what the fallback is for.

#Signature

(node: NodeLike, fallback: string | number): string

#Parameters

node
The node to key.
fallback
The key to use when the node has no instance id, such as its index.

#Example

{marks.map((mark, index) => <Mark key={nodeKey(mark, index)} node={mark} />)}

Declared in packages/canvas-sdk/src/environment/node-query.ts:181.

Last updated