Fix mobile white screen from Outlet remount loop (#54).
Unit Tests / test (pull_request) Successful in 25s
Unit Tests / test (pull_request) Successful in 25s
Stop keying protected routes with Date.now(), which remounted the dashboard on every context update, and memoize the styled-components theme so ParticleBackground stops restarting each render.
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ const ProtectedRoutes = () => {
|
|||||||
if (!authenticated) return <Navigate to='/signin/' replace />
|
if (!authenticated) return <Navigate to='/signin/' replace />
|
||||||
//if(!needsNewPassword) return <Navigate to='/password_reset/' replace/>
|
//if(!needsNewPassword) return <Navigate to='/password_reset/' replace/>
|
||||||
|
|
||||||
return <Outlet key={Date.now()} />
|
return <Outlet />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { ThemeProvider } from 'styled-components';
|
import { ThemeProvider } from 'styled-components';
|
||||||
import { useMaterialUIController } from '../../ui-kit/context';
|
import { useMaterialUIController } from '../../ui-kit/context';
|
||||||
import palettes from '../../ui-kit/assets/theme/base/palettes';
|
import palettes from '../../ui-kit/assets/theme/base/palettes';
|
||||||
@@ -11,21 +11,21 @@ const GlobalThemeWrapper = ({ children }: GlobalThemeWrapperProps): JSX.Element
|
|||||||
const [controller] = useMaterialUIController();
|
const [controller] = useMaterialUIController();
|
||||||
const { themeColor, darkMode } = controller;
|
const { themeColor, darkMode } = controller;
|
||||||
|
|
||||||
// Default to blue if themeColor is not found
|
// Stable theme ref — ParticleBackground restarts its canvas whenever theme identity changes.
|
||||||
const selectedPalette = palettes[themeColor as keyof typeof palettes] || palettes.blue;
|
const theme = useMemo(() => {
|
||||||
|
const selectedPalette = palettes[themeColor as keyof typeof palettes] || palettes.blue;
|
||||||
const theme = {
|
return {
|
||||||
main: selectedPalette.main,
|
main: selectedPalette.main,
|
||||||
focus: selectedPalette.focus,
|
focus: selectedPalette.focus,
|
||||||
darkMode: darkMode,
|
darkMode: darkMode,
|
||||||
// Add other global theme variables here if needed
|
colors: {
|
||||||
colors: {
|
background: darkMode ? '#1a2035' : '#f0f2f5',
|
||||||
background: darkMode ? '#1a2035' : '#f0f2f5',
|
text: darkMode ? '#ffffff' : '#344767',
|
||||||
text: darkMode ? '#ffffff' : '#344767',
|
cardBackground: darkMode ? 'rgba(0, 0, 0, 0.4)' : 'rgba(255, 255, 255, 0.8)',
|
||||||
cardBackground: darkMode ? 'rgba(0, 0, 0, 0.4)' : 'rgba(255, 255, 255, 0.8)',
|
cardBorder: darkMode ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.05)',
|
||||||
cardBorder: darkMode ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.05)',
|
}
|
||||||
}
|
};
|
||||||
};
|
}, [themeColor, darkMode]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
|
|||||||
Reference in New Issue
Block a user