From 1f5401472e838b1c38d97191303992cc0c5aa8e4 Mon Sep 17 00:00:00 2001
From: phantomjinx
Date: Mon, 20 Nov 2023 16:23:02 +0000
Subject: [PATCH] fix: Moves code in useEffect into main body of component #673
---
packages/hawtio/src/ui/login/HawtioLogin.tsx | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/packages/hawtio/src/ui/login/HawtioLogin.tsx b/packages/hawtio/src/ui/login/HawtioLogin.tsx
index 513865be..41826e64 100644
--- a/packages/hawtio/src/ui/login/HawtioLogin.tsx
+++ b/packages/hawtio/src/ui/login/HawtioLogin.tsx
@@ -2,7 +2,7 @@ import { useUser } from '@hawtiosrc/auth/hooks'
import { DEFAULT_APP_NAME, DEFAULT_LOGIN_TITLE, useHawtconfig, usePlugins } from '@hawtiosrc/core'
import { backgroundImages, hawtioLogo } from '@hawtiosrc/img'
import { ListItem, ListVariant, LoginFooterItem, LoginPage } from '@patternfly/react-core'
-import React, { useEffect } from 'react'
+import React from 'react'
import { useNavigate } from 'react-router-dom'
import { HawtioNotification } from '../notification'
import { HawtioLoadingPage } from '../page/HawtioLoadingPage'
@@ -16,17 +16,15 @@ export const HawtioLogin: React.FunctionComponent = () => {
const { hawtconfig, hawtconfigLoaded } = useHawtconfig()
const { plugins, pluginsLoaded } = usePlugins()
- useEffect(() => {
- if (isLogin) {
- navigate('/')
- }
- }, [isLogin, navigate])
-
if (!userLoaded || !hawtconfigLoaded || !pluginsLoaded) {
log.debug('Loading:', 'user =', userLoaded, ', hawtconfig =', hawtconfigLoaded, ', pluginsLoaded =', pluginsLoaded)
return
}
+ if (isLogin) {
+ navigate('/')
+ }
+
let loginForm =
const loginPlugins = plugins.filter(plugin => plugin.isLogin)
log.debug('Discovered Login Plugins:', loginPlugins.length)