From 343fca2e964d7abaa887b20939cd337e8de3ea4a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste WATENBERG Date: Fri, 10 Nov 2023 17:36:55 +0100 Subject: [PATCH] fix: UI was reloading everytime the token is refreshed because the redux store got re-initialized --- src/react/FederableApp.tsx | 8 +++++--- src/types/state.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/react/FederableApp.tsx b/src/react/FederableApp.tsx index 5ad0fc994..3c467ad0d 100644 --- a/src/react/FederableApp.tsx +++ b/src/react/FederableApp.tsx @@ -15,14 +15,16 @@ import MetricsAdapterProvider from './next-architecture/ui/MetricsAdapterProvide import { LocationAdapterProvider } from './next-architecture/ui/LocationAdapterProvider'; import zenkoUIReducer from './reducers'; +import { useMemo } from 'react'; const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; const InternalRouter = ({ children }: { children: React.ReactNode }) => { const config = useConfig(); - const store = createStore( - zenkoUIReducer(), - composeEnhancers(applyMiddleware(thunk)), + const store = useMemo( + () => + createStore(zenkoUIReducer(), composeEnhancers(applyMiddleware(thunk))), + [], ); return ( diff --git a/src/types/state.ts b/src/types/state.ts index 7fe7be0a7..1b623dec8 100644 --- a/src/types/state.ts +++ b/src/types/state.ts @@ -23,7 +23,7 @@ import type { ManagementClient as ManagementClientInterface } from './management import type { STSClient } from './sts'; import type { Workflows } from './workflow'; export type AuthState = { - readonly isConfigLoaded: string; + readonly isConfigLoaded: boolean; readonly isClientsLoaded: boolean; readonly configFailure: boolean; readonly managementClient: ManagementClientInterface;