add global swr config

This commit is contained in:
Alex Holliday committed 2026-03-02 22:37:58 +00:00
1 parent 6622a990be
commit a7d14e0e43
1 file changed
+36 -23
+36 -23
View File
@@ -4,39 +4,52 @@ import "react-toastify/dist/ReactToastify.css";
import { ToastContainer } from "react-toastify"; import { ToastContainer } from "react-toastify";
import { ThemeProvider } from "@emotion/react"; import { ThemeProvider } from "@emotion/react";
import { CssBaseline, GlobalStyles } from "@mui/material"; import { CssBaseline, GlobalStyles } from "@mui/material";
import { SWRConfig } from "swr";
import { Routes } from "./Routes"; import { Routes } from "./Routes";
import AppLayout from "@/Components/layout/AppLayout"; import AppLayout from "@/Components/layout/AppLayout";
import type { RootState } from "@/Types/state"; import type { RootState } from "@/Types/state";
import { lightTheme, darkTheme } from "@/Utils/Theme/Theme"; import { lightTheme, darkTheme } from "@/Utils/Theme/Theme";
const swrConfig = {
dedupingInterval: 5000,
revalidateOnFocus: false,
revalidateOnReconnect: true,
shouldRetryOnError: false,
errorRetryCount: 2,
errorRetryInterval: 1000,
focusThrottleInterval: 5000,
};
function App() { function App() {
const mode = useSelector((state: RootState) => state.ui.mode); const mode = useSelector((state: RootState) => state.ui.mode);
const theme = mode === "light" ? lightTheme : darkTheme; const theme = mode === "light" ? lightTheme : darkTheme;
return ( return (
<ThemeProvider theme={theme}> <SWRConfig value={swrConfig}>
<CssBaseline /> <ThemeProvider theme={theme}>
<GlobalStyles <CssBaseline />
styles={{ <GlobalStyles
body: { styles={{
backgroundColor: theme.palette.background.default, body: {
}, backgroundColor: theme.palette.background.default,
}} },
/> }}
<AppLayout> />
<Routes /> <AppLayout>
</AppLayout> <Routes />
<ToastContainer </AppLayout>
newestOnTop={true} <ToastContainer
theme={mode} newestOnTop={true}
style={ theme={mode}
{ style={
"--toastify-color-progress-light": "#7C8BA1", {
"--toastify-color-progress-dark": "#7C8BA1", "--toastify-color-progress-light": "#7C8BA1",
} as CSSProperties "--toastify-color-progress-dark": "#7C8BA1",
} } as CSSProperties
/> }
</ThemeProvider> />
</ThemeProvider>
</SWRConfig>
); );
} }