OnNodesChange
This type is used for typing the onNodesChange function.
export type OnNodesChange<NodeType extends Node = Node> = (
changes: NodeChangeset<NodeType>,
) => void;Fields
Parameters:| Name | Type | Default |
|---|---|---|
changes | NodeChangeset<NodeType> |
Usage
This type accepts a generic type argument of custom nodes types. See this section in our TypeScript guide for more information.
onNodesChange is now called with a NodeChangeset instead of a plain
NodeChange[] array. Apply it with the changeset’s own applyTo() method:
const onNodesChange: OnNodesChange = (changes) => {
nodes = changes.applyTo(nodes);
};