Skip to content

Commit 8f9fcc3

Browse files
committed
fix: tanstack query integration
1 parent ac8d561 commit 8f9fcc3

2 files changed

Lines changed: 5 additions & 45 deletions

File tree

packages/create/src/frameworks/react/add-ons/tanstack-query/assets/src/integrations/tanstack-query/root-provider.tsx.ejs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,31 +62,4 @@ export default function TanStackQueryProvider({
6262
</QueryClientProvider>
6363
)
6464
}
65-
<% } else { %>
66-
import type { ReactNode } from 'react'
67-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
68-
69-
export function getContext() {
70-
const queryClient = new QueryClient();
71-
72-
return {
73-
queryClient,
74-
}
75-
}
76-
77-
export default function TanStackQueryProvider({
78-
children,
79-
context,
80-
}: {
81-
children: ReactNode
82-
context: ReturnType<typeof getContext>
83-
}) {
84-
const { queryClient } = context
85-
86-
return (
87-
<QueryClientProvider client={queryClient}>
88-
{children}
89-
</QueryClientProvider>
90-
)
91-
}
9265
<% } %>

packages/create/src/frameworks/react/project/base/src/router.tsx.ejs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,27 @@
11
import { createRouter as createTanStackRouter } from '@tanstack/react-router'
22
import { routeTree } from './routeTree.gen'
33
<% if (addOnEnabled['tanstack-query']) { %>
4+
import { QueryClient } from '@tanstack/react-query'
45
import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
5-
import TanStackQueryProvider, {
6-
getContext,
7-
} from "./integrations/tanstack-query/root-provider";
86
<% } %>
97

108
export function getRouter() {
119
<% if (addOnEnabled['tanstack-query']) { %>
12-
const context = getContext();
10+
const queryClient = new QueryClient();
1311
<% } %>
1412

1513
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']) { %>
2016
context: {} as any,
2117
<% } %>
2218
scrollRestoration: true,
2319
defaultPreload: 'intent',
2420
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-
<% } %>
3421
})
3522

3623
<% if (addOnEnabled['tanstack-query']) { %>
37-
setupRouterSsrQueryIntegration({ router, queryClient: context.queryClient })
24+
setupRouterSsrQueryIntegration({ router, queryClient: queryClient })
3825
<% } %>
3926

4027
return router

0 commit comments

Comments
 (0)