Merge pull request #4015 from xyflow/fix-useNodesData-crash

Fix use nodes data crash
This commit is contained in:
Moritz Klack
2024-03-14 13:03:07 +01:00
committed by GitHub
2 changed files with 11 additions and 1 deletions
+6
View File
@@ -1,5 +1,11 @@
# @xyflow/react
## 12.0.0-next.12
## Patch changes
- fix useNodesData: handle invalid node id thanks @saswatax
## 12.0.0-next.11
## Patch changes
@@ -2,7 +2,11 @@ import { NodeBase } from '../types';
type NodeData = Pick<NodeBase, 'id' | 'type' | 'data'>;
export function shallowNodeData(a: NodeData | NodeData[], b: NodeData | NodeData[]) {
export function shallowNodeData(a: NodeData | NodeData[] | null, b: NodeData | NodeData[] | null) {
if (a === null || b === null) {
return false;
}
const _a = Array.isArray(a) ? a : [a];
const _b = Array.isArray(b) ? b : [b];