From 9cda0860221a6e94debb08e61fccfb758378f7bc Mon Sep 17 00:00:00 2001 From: Devessier Date: Thu, 22 Aug 2024 17:11:55 +0200 Subject: [PATCH] refactor: drop useless useMemo and compute directly in useEffect --- .../pages/workflows/WorkflowShowPageEffect.tsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/twenty-front/src/pages/workflows/WorkflowShowPageEffect.tsx b/packages/twenty-front/src/pages/workflows/WorkflowShowPageEffect.tsx index ac6a63537ecdd..dce3204b50425 100644 --- a/packages/twenty-front/src/pages/workflows/WorkflowShowPageEffect.tsx +++ b/packages/twenty-front/src/pages/workflows/WorkflowShowPageEffect.tsx @@ -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'; @@ -127,16 +127,6 @@ export const WorkflowShowPageEffect = ({ }, }); - const flowLastVersion = useMemo( - () => getFlowLastVersion(workflow), - [workflow], - ); - - const flowWithCreateStepNodes = useMemo( - () => addCreateStepNodes(flowLastVersion), - [flowLastVersion], - ); - const setCurrentWorkflowData = useSetRecoilState( showPageWorkflowDiagramState, ); @@ -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);