From 244a9a6e8e14e34b94fa56053660f85ebfb13a5b Mon Sep 17 00:00:00 2001 From: Tahier Hussain Date: Thu, 30 Jan 2025 14:57:32 +0530 Subject: [PATCH] Code optimization in declaring variable --- .../input-output/add-source/AddSource.jsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/input-output/add-source/AddSource.jsx b/frontend/src/components/input-output/add-source/AddSource.jsx index 10f047bc7..96fb5d60a 100644 --- a/frontend/src/components/input-output/add-source/AddSource.jsx +++ b/frontend/src/components/input-output/add-source/AddSource.jsx @@ -1,6 +1,6 @@ import { Typography } from "antd"; import PropTypes from "prop-types"; -import { useEffect, useState } from "react"; +import { useEffect, useMemo, useState } from "react"; import { sourceTypes } from "../../../helpers/GetStaticData"; import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate"; @@ -49,7 +49,6 @@ function AddSource({ const { setAlertDetails } = useAlertStore(); const axiosPrivate = useAxiosPrivate(); const handleException = useExceptionHandler(); - const [isLLMWPaidSchema, setIsLLMWPaidSchema] = useState(false); let transformLlmWhispererFormData; try { @@ -67,13 +66,13 @@ function AddSource({ ); } - useEffect(() => { - setIsLLMWPaidSchema( + const isLLMWPaidSchema = useMemo(() => { + return ( LLMW_V2_ID && - transformLlmWhispererJsonSchema && - PLAN_TYPES && - selectedSourceId === LLMW_V2_ID && - planType === PLAN_TYPES?.PAID + transformLlmWhispererJsonSchema && + PLAN_TYPES && + selectedSourceId === LLMW_V2_ID && + planType === PLAN_TYPES?.PAID ); }, [ LLMW_V2_ID,