Skip to content

Commit

Permalink
refactor: drop useless useMemo and compute directly in useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
Devessier committed Aug 22, 2024
1 parent e92a156 commit 9cda086
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@/workflow/types/WorkflowDiagram';
import { addCreateStepNodes } from '@/workflow/utils/addCreateStepNodes';
import { MarkerType } from '@xyflow/react';
import { useEffect, useMemo } from 'react';
import { useEffect } from 'react';
import { useSetRecoilState } from 'recoil';
import { isDefined } from 'twenty-ui';
import { v4 } from 'uuid';
Expand Down Expand Up @@ -127,16 +127,6 @@ export const WorkflowShowPageEffect = ({
},
});

const flowLastVersion = useMemo(
() => getFlowLastVersion(workflow),
[workflow],
);

const flowWithCreateStepNodes = useMemo(
() => addCreateStepNodes(flowLastVersion),
[flowLastVersion],
);

const setCurrentWorkflowData = useSetRecoilState(
showPageWorkflowDiagramState,
);
Expand All @@ -146,10 +136,13 @@ export const WorkflowShowPageEffect = ({
const setCurrentWorkflowError = useSetRecoilState(showPageWorkflowErrorState);

useEffect(() => {
const flowLastVersion = getFlowLastVersion(workflow);
const flowWithCreateStepNodes = addCreateStepNodes(flowLastVersion);

setCurrentWorkflowData(
isDefined(workflow) ? flowWithCreateStepNodes : undefined,
);
}, [flowWithCreateStepNodes, setCurrentWorkflowData, workflow]);
}, [setCurrentWorkflowData, workflow]);

useEffect(() => {
setCurrentWorkflowLoading(loading);
Expand Down

0 comments on commit 9cda086

Please sign in to comment.