-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouterProvider.tsx
40 lines (34 loc) · 1.26 KB
/
routerProvider.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
import { createRouter, RouterProvider as TanstackRouterProvider } from '@tanstack/react-router';
import { routeTree } from 'src/router/routesConfig';
import { Loading } from 'src/components/loading/loading';
import { ErrorBoundary } from 'src/components/errorBoundary/errorBoundary';
import { NotFound } from 'src/components/notFound/notFound';
import { SectionName } from '~bootstrap';
/**
* This is the place to configure tanstack router.
* It exports the RouterProvider component to be included in the react tree and the router object to be used outside react
*/
/**
* You can configure the router defaults here
* https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType
*/
const router = createRouter({
routeTree,
defaultPendingMs: 0,
defaultPendingComponent: Loading,
defaultErrorComponent: ErrorBoundary,
defaultNotFoundComponent: NotFound,
defaultPreloadStaleTime: 0, // we set this to 0 because we are using an external cache (tanstack query)
});
declare module '@tanstack/react-router' {
interface Register {
router: typeof router;
}
interface StaticDataRouteOption {
underSection?: SectionName;
}
}
function RouterProvider() {
return <TanstackRouterProvider router={router} />;
}
export { RouterProvider, router };