OnNodesChange

This type is used for typing the onNodesChange function.

export type OnNodesChange<NodeType extends Node = Node> = (
  changes: NodeChange<NodeType>[],
) => void;

Fields

This type can be used to type the onNodesChange function with a custom node type.

Parameters
  • changes: NodeChange<NodeType>[]
Returns

void

Usage

This type accepts a generic type argument of custom nodes types. See this section in our TypeScript guide for more information.

const onNodesChange: OnNodesChange = useCallback(
  (changes) => setNodes((nds) => applyNodeChanges(changes, nds)),
  [setNodes],
);