-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
38 lines (34 loc) · 986 Bytes
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { useEffect, useState } from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { ReactQueryDevtools } from 'react-query/devtools';
import './App.css';
import Router from './shared/Router';
import { onAuthStateChanged } from 'firebase/auth';
import { auth } from './firebase';
import { useNavigate } from 'react-router-dom';
import { accessToken } from './components/Header';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retry: 1
}
}
});
function App() {
const navigate = useNavigate();
const [render, setRender] = useState(false);
useEffect(() => {
onAuthStateChanged(auth, (user) => {
if (!user || !accessToken) navigate('/login');
setRender(true);
});
}, []);
return (
<QueryClientProvider client={queryClient}>
<Router />
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
);
}
export default App;