We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 11ecd17 commit 2c5609fCopy full SHA for 2c5609f
frontend/src/pages/Root.js
@@ -1,9 +1,23 @@
1
-import { Outlet, useNavigation } from 'react-router-dom';
+import { Outlet, useLoaderData, useSubmit } from 'react-router-dom';
2
3
import MainNavigation from '../components/MainNavigation';
4
+import { useEffect } from 'react';
5
6
function RootLayout() {
7
+ const token = useLoaderData();
8
+ const submit = useSubmit();
9
// const navigation = useNavigation();
10
+ useEffect(() => {
11
+ if (!token) {
12
+ return;
13
+ }
14
+
15
+ const timeout = 1 * 60 * 60 * 1000; // 1 hour
16
17
+ setTimeout(() => {
18
+ submit(null, { action: '/logout', method: 'post' });
19
+ }, timeout);
20
+ }, [token, submit]);
21
22
return (
23
<>
0 commit comments