chore(middleware): cleanup

This commit is contained in:
moklick
2025-12-02 16:40:26 +01:00
parent e4e3605d62
commit a523919d67
3 changed files with 17 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
'@xyflow/react': patch
---
Add `experimental_useOnNodesChangeMiddleware` hook

View File

@@ -4,6 +4,12 @@ import type { EdgeChange } from '@xyflow/system';
import { useStoreApi } from './useStore';
import type { Edge, Node } from '../types';
/**
* Registers a middleware function to transform edge changes.
*
* @public
* @param fn - Middleware function. Should be memoized with useCallback to avoid re-registration.
*/
export function experimental_useOnEdgesChangeMiddleware<EdgeType extends Edge = Edge>(
fn: (changes: EdgeChange<EdgeType>[]) => EdgeChange<EdgeType>[]
) {

View File

@@ -4,6 +4,12 @@ import type { NodeChange } from '@xyflow/system';
import { useStoreApi } from './useStore';
import type { Edge, Node } from '../types';
/**
* Registers a middleware function to transform node changes.
*
* @public
* @param fn - Middleware function. Should be memoized with useCallback to avoid re-registration.
*/
export function experimental_useOnNodesChangeMiddleware<NodeType extends Node = Node>(
fn: (changes: NodeChange<NodeType>[]) => NodeChange<NodeType>[]
) {