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
+13
+13
View File
@@ -4,16 +4,28 @@ 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 (
<SWRConfig value={swrConfig}>
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<CssBaseline /> <CssBaseline />
<GlobalStyles <GlobalStyles
@@ -37,6 +49,7 @@ function App() {
} }
/> />
</ThemeProvider> </ThemeProvider>
</SWRConfig>
); );
} }