From 928433771e5aab8e19e7e1ef40b79cd922ce617b Mon Sep 17 00:00:00 2001 From: Vadym Pavlyk Date: Tue, 26 Nov 2024 12:10:57 +0200 Subject: [PATCH] Extract default tab into a variable --- .../cooperation-details/CooperationDetails.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx b/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx index 81d8c0892..796d242f9 100644 --- a/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx +++ b/src/containers/my-cooperations/cooperation-details/CooperationDetails.tsx @@ -61,13 +61,15 @@ const CooperationDetails = () => { const isTabInSearchParams = Object.values(CooperationTabsEnum).includes(tab) - const activeTab = isTabInSearchParams ? tab : CooperationTabsEnum.Activities + const defaultTab = CooperationTabsEnum.Activities + + const activeTab = isTabInSearchParams ? tab : defaultTab useEffect(() => { if (!isTabInSearchParams) { - setSearchParams({ tab: CooperationTabsEnum.Activities }) + setSearchParams({ tab: defaultTab }) } - }, [isTabInSearchParams, setSearchParams]) + }, [defaultTab, isTabInSearchParams, setSearchParams]) const responseError = useCallback( () => navigate(errorRoutes.notFound.path),