chore(node-toolbar): cleanup

This commit is contained in:
moklick
2022-11-25 21:35:39 +01:00
parent ec94d9ecdc
commit 1363d1e398
2 changed files with 15 additions and 9 deletions
+7 -5
View File
@@ -72,17 +72,19 @@ function NodeToolbar({
offset = 10,
...rest
}: NodeToolbarProps) {
const nodeIds: string[] = typeof nodeId === 'string' ? [nodeId] : nodeId;
const nodesSelector = useCallback(
(state: ReactFlowState): Node[] =>
nodeIds.reduce<Node[]>((acc, id) => {
(state: ReactFlowState): Node[] => {
const nodeIds: string[] = typeof nodeId === 'string' ? [nodeId] : nodeId;
return nodeIds.reduce<Node[]>((acc, id) => {
const node = state.nodeInternals.get(id);
if (node) {
acc.push(node);
}
return acc;
}, [] as Node[]),
[nodeIds]
}, [] as Node[]);
},
[nodeId]
);
const nodes = useStore(nodesSelector, nodesEqualityFn);
const { transform, nodeOrigin, selectedNodesCount } = useStore(storeSelector, shallow);