|
1 | 1 | import { createRouter as createTanStackRouter } from '@tanstack/react-router' |
2 | 2 | import { routeTree } from './routeTree.gen' |
3 | 3 | <% if (addOnEnabled['tanstack-query']) { %> |
| 4 | +import { QueryClient } from '@tanstack/react-query' |
4 | 5 | import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query"; |
5 | | -import TanStackQueryProvider, { |
6 | | - getContext, |
7 | | -} from "./integrations/tanstack-query/root-provider"; |
8 | 6 | <% } %> |
9 | 7 |
|
10 | 8 | export function getRouter() { |
11 | 9 | <% if (addOnEnabled['tanstack-query']) { %> |
12 | | - const context = getContext(); |
| 10 | + const queryClient = new QueryClient(); |
13 | 11 | <% } %> |
14 | 12 |
|
15 | 13 | const router = createTanStackRouter({ |
16 | | - routeTree, |
17 | | -<% if (addOnEnabled['tanstack-query']) { %> |
18 | | - context, |
19 | | -<% } else if (addOnEnabled['apollo-client']) { %> |
| 14 | + routeTree,<% if (addOnEnabled['tanstack-query']) { %> |
| 15 | + context: { queryClient },<% } else if (addOnEnabled['apollo-client']) { %> |
20 | 16 | context: {} as any, |
21 | 17 | <% } %> |
22 | 18 | scrollRestoration: true, |
23 | 19 | defaultPreload: 'intent', |
24 | 20 | defaultPreloadStaleTime: 0, |
25 | | -<% if (addOnEnabled['tanstack-query']) { %> |
26 | | - Wrap: (props: { children: React.ReactNode }) => { |
27 | | - return ( |
28 | | - <TanStackQueryProvider context={context}> |
29 | | - {props.children} |
30 | | - </TanStackQueryProvider> |
31 | | - ); |
32 | | - }, |
33 | | -<% } %> |
34 | 21 | }) |
35 | 22 |
|
36 | 23 | <% if (addOnEnabled['tanstack-query']) { %> |
37 | | - setupRouterSsrQueryIntegration({ router, queryClient: context.queryClient }) |
| 24 | + setupRouterSsrQueryIntegration({ router, queryClient: queryClient }) |
38 | 25 | <% } %> |
39 | 26 |
|
40 | 27 | return router |
|
0 commit comments