Skip to content

Commit 52741d9

Browse files
committed
fix: biome and start plus tanstack-query
1 parent 2ee0def commit 52741d9

File tree

8 files changed

+56
-34
lines changed

8 files changed

+56
-34
lines changed

templates/react/add-on/form/assets/src/components/demo.FormComponents.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export function SubscribeButton({ label }: { label: string }) {
77
<form.Subscribe selector={(state) => state.isSubmitting}>
88
{(isSubmitting) => (
99
<button
10+
type="submit"
1011
disabled={isSubmitting}
1112
className="px-6 py-2 bg-indigo-600 text-white rounded-md hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition-colors disabled:opacity-50"
1213
>

templates/react/add-on/form/assets/src/routes/demo.form.address.tsx.ejs

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ function AddressForm() {
6161
}}
6262
className="space-y-6"
6363
>
64-
<form.AppField
65-
name="fullName"
66-
children={(field) => <field.TextField label="Full Name" />}
67-
/>
64+
<form.AppField name="fullName">
65+
{(field) => <field.TextField label="Full Name" />}
66+
</form.AppField>
6867

6968
<form.AppField
7069
name="email"
@@ -79,8 +78,9 @@ function AddressForm() {
7978
return undefined
8079
},
8180
}}
82-
children={(field) => <field.TextField label="Email" />}
83-
/>
81+
>
82+
{(field) => <field.TextField label="Email" />}
83+
</form.AppField>
8484

8585
<form.AppField
8686
name="address.street"
@@ -92,8 +92,9 @@ function AddressForm() {
9292
return undefined
9393
},
9494
}}
95-
children={(field) => <field.TextField label="Street Address" />}
96-
/>
95+
>
96+
{(field) => <field.TextField label="Street Address" />}
97+
</form.AppField>
9798

9899
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
99100
<form.AppField
@@ -106,8 +107,9 @@ function AddressForm() {
106107
return undefined
107108
},
108109
}}
109-
children={(field) => <field.TextField label="City" />}
110-
/>
110+
>
111+
{(field) => <field.TextField label="City" />}
112+
</form.AppField>
111113
<form.AppField
112114
name="address.state"
113115
validators={{
@@ -118,8 +120,9 @@ function AddressForm() {
118120
return undefined
119121
},
120122
}}
121-
children={(field) => <field.TextField label="State" />}
122-
/>
123+
>
124+
{(field) => <field.TextField label="State" />}
125+
</form.AppField>
123126
<form.AppField
124127
name="address.zipCode"
125128
validators={{
@@ -133,8 +136,9 @@ function AddressForm() {
133136
return undefined
134137
},
135138
}}
136-
children={(field) => <field.TextField label="Zip Code" />}
137-
/>
139+
>
140+
{(field) => <field.TextField label="Zip Code" />}
141+
</form.AppField>
138142
</div>
139143

140144
<form.AppField
@@ -147,7 +151,8 @@ function AddressForm() {
147151
return undefined
148152
},
149153
}}
150-
children={(field) => (
154+
>
155+
{(field) => (
151156
<field.Select label="Country">
152157
<option value="">Select a country</option>
153158
<option value="US">United States</option>
@@ -159,7 +164,7 @@ function AddressForm() {
159164
<option value="JP">Japan</option>
160165
</field.Select>
161166
)}
162-
/>
167+
</form.AppField>
163168

164169
<form.AppField
165170
name="phone"
@@ -178,10 +183,11 @@ function AddressForm() {
178183
return undefined
179184
},
180185
}}
181-
children={(field) => (
186+
>
187+
{(field) => (
182188
<field.TextField label="Phone" placeholder="123-456-7890" />
183189
)}
184-
/>
190+
</form.AppField>
185191

186192
<div className="flex justify-end">
187193
<form.AppForm>
@@ -194,6 +200,7 @@ function AddressForm() {
194200
)
195201
}
196202

203+
197204
<% if (codeRouter) { %>
198205
export default (parentRoute: RootRoute) => createRoute({
199206
path: '/demo/form',

templates/react/add-on/form/assets/src/routes/demo.form.simple.tsx.ejs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ function SimpleForm() {
4949
}}
5050
className="space-y-6"
5151
>
52-
<form.AppField
53-
name="title"
54-
children={(field) => <field.TextField label="Title" />}
55-
/>
52+
<form.AppField name="title">
53+
{(field) => <field.TextField label="Title" />}
54+
</form.AppField>
5655

57-
<form.AppField
58-
name="description"
59-
children={(field) => <field.TextArea label="Description" />}
60-
/>
56+
<form.AppField name="description">
57+
{(field) => <field.TextArea label="Description" />}
58+
</form.AppField>
6159

6260
<div className="flex justify-end">
6361
<form.AppForm>

templates/react/add-on/start/assets/src/router.tsx.ejs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,39 @@ import { createRouter as createTanstackRouter } from '@tanstack/react-router'<%
22
import * as Sentry from '@sentry/react'
33
import * as SentryServer from '@sentry/node'
44
import { createIsomorphicFn } from '@tanstack/react-start'
5+
<% } %><% if (addOnEnabled['tanstack-query']) { %>
6+
import { routerWithQueryClient } from '@tanstack/react-router-with-query'
7+
import * as TanstackQuery from './integrations/tanstack-query/root-provider'
58
<% } %>
6-
9+
710
// Import the generated route tree
811
import { routeTree } from './routeTree.gen'
912

1013
import './styles.css'
1114

1215
// Create a new router instance
1316
export const createRouter = () => {
17+
<% if (addOnEnabled['tanstack-query']) { %>
18+
const router = routerWithQueryClient(createTanstackRouter({
19+
routeTree,
20+
context: {
21+
<% if (addOnEnabled['tanstack-query']) { %>
22+
...TanstackQuery.getContext(),
23+
<% } %>
24+
},
25+
scrollRestoration: true,
26+
}), TanstackQuery.getContext().queryClient)
27+
<% } else { %>
1428
const router = createTanstackRouter({
1529
routeTree,
1630
scrollRestoration: true,
1731
})
32+
<% } %>
1833
return router
1934
}
2035

21-
const router = createRouter()
22-
2336
<% if (addOnEnabled.sentry) { %>
37+
const router = createRouter()
2438
createIsomorphicFn().server(() => {
2539
SentryServer.init({
2640
dsn: import.meta.env.VITE_SENTRY_DSN,
@@ -44,8 +58,6 @@ const router = createRouter()
4458
})()
4559
<% } %>
4660

47-
48-
4961
// Register the router instance for type safety
5062
declare module '@tanstack/react-router' {
5163
interface Register {

templates/react/add-on/start/assets/src/routes/demo.start.server-funcs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as fs from 'fs'
1+
import * as fs from 'node:fs'
22
import { createFileRoute, useRouter } from '@tanstack/react-router'
33
import { createServerFn } from '@tanstack/react-start'
44

@@ -35,6 +35,7 @@ function Home() {
3535
return (
3636
<div className="p-4">
3737
<button
38+
type="button"
3839
onClick={() => {
3940
updateCount({ data: 1 }).then(() => {
4041
router.invalidate()

templates/react/add-on/start/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"start": "vinxi start"
66
},
77
"dependencies": {
8+
"@tanstack/react-router-with-query": "^1.114.3",
89
"@tailwindcss/postcss": "^4.0.7",
910
"@tanstack/react-start": "^1.114.3",
1011
"postcss": "^8.5.2",

templates/react/base/src/components/Header.tsx.ejs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ export default function Header() {
1515
<div className="px-2 font-bold"><Link to="<%= route.url %>"><%= route.name %></Link></div>
1616
<% } } %>
1717
</nav>
18+
<% if (integrations.filter(i => i.type === 'header-user').length > 0) { %>
1819
<div>
1920
<% for(const integration of integrations.filter(i => i.type === 'header-user')) { %>
2021
<<%= integration.name %> />
2122
<% } %>
22-
</div>
23+
</div>
24+
<% } %>
2325
</header>
2426
)
2527
}

templates/react/file-router/src/routes/__root.tsx.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const Route = createRootRoute({
5757
<% if (addOnEnabled.start) { %>
5858
function RootDocument({ children }: { children: React.ReactNode }) {
5959
return (
60-
<html>
60+
<html lang="en">
6161
<head>
6262
<HeadContent />
6363
</head>

0 commit comments

Comments
 (0)