Skip to content

Commit

Permalink
chore: update flow hook and store method signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
youngjuning committed Dec 31, 2024
1 parent d78ceb6 commit 3cdddff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/x-flow/src/hooks/useFlow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export const useFlow = () => {
const setNodes = useMemoizedFn((nodes: FlowNode[]) => {
storeApi.getState().setNodes(nodes);
});
const addNodes = useMemoizedFn((nodes: FlowNode[]) => {
storeApi.getState().addNodes(nodes);
const addNodes = useMemoizedFn((nodes: FlowNode[], isVanilla = true) => {
storeApi.getState().addNodes(nodes, isVanilla);
});
const setEdges = useMemoizedFn((edges: Edge[]) => {
storeApi.getState().setEdges(edges);
Expand Down
6 changes: 3 additions & 3 deletions packages/x-flow/src/models/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type FlowState = {
onConnect: OnConnect;
setNodes: (nodes: FlowNode[]) => void;
setEdges: (edges: Edge[]) => void;
addNodes: (nodes: FlowNode[]| FlowNode) => void;
addNodes: (nodes: FlowNode[]| FlowNode, isVanilla?: boolean) => void;
addEdges: (edges: Edge[] | Edge) => void;
deleteNode: (nodeId: string) => void;
copyNode: (nodeId: string) => void;
Expand Down Expand Up @@ -96,9 +96,9 @@ const createStore = (initProps?: Partial<FlowProps>) => {
getEdges: () => {
return get().nodes;
},
addNodes: payload => {
addNodes: (payload, isVanilla = true) => {
const newNodes = get().nodes.concat(payload);
set({ nodes: newNodes });
set({ nodes: isVanilla ? newNodes : transformNodes(newNodes) });
},
addEdges: payload => {
set({ edges: get().edges.concat(payload) });
Expand Down

0 comments on commit 3cdddff

Please sign in to comment.