-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
_app.tsx
52 lines (47 loc) · 1.61 KB
/
_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { type Atom, Provider } from 'jotai';
import { SessionProvider } from 'next-auth/react';
import type { AppProps } from 'next/app';
import logger from '../logger';
import store from '../store';
import '../styles/globals.css';
if (process.env.NEXT_PUBLIC_API_MOCKING === 'yes') {
if (typeof window === 'undefined') {
import('../mocks/server')
.then(({ server }) => {
server.listen();
})
.catch(logger.error);
} else {
import('../mocks/browser')
.then(async ({ browser }) => browser.start())
.catch(logger.error);
}
}
const queryClient = new QueryClient();
function MyApp({ Component, pageProps }: AppProps) {
const { initialState } = pageProps;
return (
<Provider
// @ts-expect-error initialValue is not in the types
initialValues={
initialState &&
([[store.counterAtom, initialState]] as Iterable<
readonly [Atom<unknown>, unknown]
>)
}
>
<SessionProvider
session={pageProps.session}
refetchInterval={5 * 60}
>
<QueryClientProvider client={queryClient}>
<Component {...pageProps} />
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
</SessionProvider>
</Provider>
);
}
export default MyApp;