From 7cf998c50901e0e32e9d9d9ccddf3f681ce6fd32 Mon Sep 17 00:00:00 2001 From: Thomas Heartman Date: Fri, 3 Nov 2023 11:04:03 +0100 Subject: [PATCH] fix: move useUiFlag before "return null" to avoid rendering more hooks on the first render (#5258) Move the hook to before the first return to avoid React erroring out. --- .../ChangeRequestOverview/ChangeRequestOverview.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx index fb613e6c26..dbe21e4ad6 100644 --- a/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx +++ b/frontend/src/component/changeRequest/ChangeRequestOverview/ChangeRequestOverview.tsx @@ -86,12 +86,12 @@ export const ChangeRequestOverview: FC = () => { const { isChangeRequestConfiguredForReview } = useChangeRequestsEnabled(projectId); + const scheduleChangeRequests = useUiFlag('scheduledConfigurationChanges'); + if (!changeRequest) { return null; } - const scheduleChangeRequests = useUiFlag('scheduledConfigurationChanges'); - const allowChangeRequestActions = isChangeRequestConfiguredForReview( changeRequest.environment, );