Skip to content

Commit

Permalink
Overide SWR config in admin area (#2567)
Browse files Browse the repository at this point in the history
Change `revalidateOnFocus` to true since the admin often open many tabs
  • Loading branch information
notmd committed Apr 15, 2023
1 parent 8cc737b commit c8b5eed
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion website/src/components/AdminArea.tsx
@@ -1,6 +1,11 @@
import { useRouter } from "next/router";
import { useSession } from "next-auth/react";
import { ReactNode, useEffect } from "react";
import { SWRConfig, SWRConfiguration } from "swr";
const swrConfig: SWRConfiguration = {
revalidateOnFocus: true,
revalidateOnMount: true,
};

export const AdminArea = ({ children }: { children: ReactNode }) => {
const router = useRouter();
Expand All @@ -18,5 +23,10 @@ export const AdminArea = ({ children }: { children: ReactNode }) => {

router.push("/");
}, [router, session, status]);
return <main>{status === "loading" ? "loading..." : children}</main>;

return (
<SWRConfig value={swrConfig}>
<main>{status === "loading" ? "loading..." : children}</main>;
</SWRConfig>
);
};

0 comments on commit c8b5eed

Please sign in to comment.