Skip to content

Commit 4cfe6cc

Browse files
ci: apply automated fixes
1 parent ea11a17 commit 4cfe6cc

File tree

5 files changed

+54
-59
lines changed

5 files changed

+54
-59
lines changed

examples/react/start/.cta.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
"git": true,
88
"version": 1,
99
"framework": "react-cra",
10-
"chosenAddOns": [
11-
"start"
12-
]
13-
}
10+
"chosenAddOns": ["start"]
11+
}

examples/react/start/README.md

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
Welcome to your new TanStack app!
1+
Welcome to your new TanStack app!
22

33
# Getting Started
44

55
To run this application:
66

77
```bash
88
pnpm install
9-
pnpm start
9+
pnpm start
1010
```
1111

1212
# Building For Production
@@ -29,10 +29,8 @@ pnpm test
2929

3030
This project uses [Tailwind CSS](https://tailwindcss.com/) for styling.
3131

32-
33-
34-
3532
## Routing
33+
3634
This project uses [TanStack Router](https://tanstack.com/router). The initial setup is a file based router. Which means that the routes are managed as files in `src/routes`.
3735

3836
### Adding A Route
@@ -48,7 +46,7 @@ Now that you have two routes you can use a `Link` component to navigate between
4846
To use SPA (Single Page Application) navigation you will need to import the `Link` component from `@tanstack/react-router`.
4947

5048
```tsx
51-
import { Link } from "@tanstack/react-router";
49+
import { Link } from '@tanstack/react-router'
5250
```
5351

5452
Then anywhere in your JSX you can use it like so:
@@ -71,7 +69,7 @@ Here is an example layout that includes a header:
7169
import { Outlet, createRootRoute } from '@tanstack/react-router'
7270
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
7371

74-
import { Link } from "@tanstack/react-router";
72+
import { Link } from '@tanstack/react-router'
7573

7674
export const Route = createRootRoute({
7775
component: () => (
@@ -93,7 +91,6 @@ The `<TanStackRouterDevtools />` component is not required so you can remove it
9391

9492
More information on layouts can be found in the [Layouts documentation](https://tanstack.com/router/latest/docs/framework/react/guide/routing-concepts#layouts).
9593

96-
9794
## Data Fetching
9895

9996
There are multiple ways to fetch data in your application. You can use TanStack Query to fetch data from a server. But you can also use the `loader` functionality built into TanStack Router to load the data for a route before it's rendered.
@@ -103,26 +100,26 @@ For example:
103100
```tsx
104101
const peopleRoute = createRoute({
105102
getParentRoute: () => rootRoute,
106-
path: "/people",
103+
path: '/people',
107104
loader: async () => {
108-
const response = await fetch("https://swapi.dev/api/people");
105+
const response = await fetch('https://swapi.dev/api/people')
109106
return response.json() as Promise<{
110107
results: {
111-
name: string;
112-
}[];
113-
}>;
108+
name: string
109+
}[]
110+
}>
114111
},
115112
component: () => {
116-
const data = peopleRoute.useLoaderData();
113+
const data = peopleRoute.useLoaderData()
117114
return (
118115
<ul>
119116
{data.results.map((person) => (
120117
<li key={person.name}>{person.name}</li>
121118
))}
122119
</ul>
123-
);
120+
)
124121
},
125-
});
122+
})
126123
```
127124

128125
Loaders simplify your data fetching logic dramatically. Check out more information in the [Loader documentation](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#loader-parameters).
@@ -140,29 +137,29 @@ pnpm add @tanstack/react-query @tanstack/react-query-devtools
140137
Next we'll need to create a query client and provider. We recommend putting those in `main.tsx`.
141138

142139
```tsx
143-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
140+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
144141

145142
// ...
146143

147-
const queryClient = new QueryClient();
144+
const queryClient = new QueryClient()
148145

149146
// ...
150147

151148
if (!rootElement.innerHTML) {
152-
const root = ReactDOM.createRoot(rootElement);
149+
const root = ReactDOM.createRoot(rootElement)
153150

154151
root.render(
155152
<QueryClientProvider client={queryClient}>
156153
<RouterProvider router={router} />
157-
</QueryClientProvider>
158-
);
154+
</QueryClientProvider>,
155+
)
159156
}
160157
```
161158

162159
You can also add TanStack Query Devtools to the root route (optional).
163160

164161
```tsx
165-
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
162+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
166163

167164
const rootRoute = createRootRoute({
168165
component: () => (
@@ -172,25 +169,25 @@ const rootRoute = createRootRoute({
172169
<TanStackRouterDevtools />
173170
</>
174171
),
175-
});
172+
})
176173
```
177174

178175
Now you can use `useQuery` to fetch your data.
179176

180177
```tsx
181-
import { useQuery } from "@tanstack/react-query";
178+
import { useQuery } from '@tanstack/react-query'
182179

183-
import "./App.css";
180+
import './App.css'
184181

185182
function App() {
186183
const { data } = useQuery({
187-
queryKey: ["people"],
184+
queryKey: ['people'],
188185
queryFn: () =>
189-
fetch("https://swapi.dev/api/people")
186+
fetch('https://swapi.dev/api/people')
190187
.then((res) => res.json())
191188
.then((data) => data.results as { name: string }[]),
192189
initialData: [],
193-
});
190+
})
194191

195192
return (
196193
<div>
@@ -200,10 +197,10 @@ function App() {
200197
))}
201198
</ul>
202199
</div>
203-
);
200+
)
204201
}
205202

206-
export default App;
203+
export default App
207204
```
208205

209206
You can find out everything you need to know on how to use React-Query in the [React-Query documentation](https://tanstack.com/query/latest/docs/framework/react/overview).
@@ -221,46 +218,46 @@ pnpm add @tanstack/store
221218
Now let's create a simple counter in the `src/App.tsx` file as a demonstration.
222219

223220
```tsx
224-
import { useStore } from "@tanstack/react-store";
225-
import { Store } from "@tanstack/store";
226-
import "./App.css";
221+
import { useStore } from '@tanstack/react-store'
222+
import { Store } from '@tanstack/store'
223+
import './App.css'
227224

228-
const countStore = new Store(0);
225+
const countStore = new Store(0)
229226

230227
function App() {
231-
const count = useStore(countStore);
228+
const count = useStore(countStore)
232229
return (
233230
<div>
234231
<button onClick={() => countStore.setState((n) => n + 1)}>
235232
Increment - {count}
236233
</button>
237234
</div>
238-
);
235+
)
239236
}
240237

241-
export default App;
238+
export default App
242239
```
243240

244241
One of the many nice features of TanStack Store is the ability to derive state from other state. That derived state will update when the base state updates.
245242

246243
Let's check this out by doubling the count using derived state.
247244

248245
```tsx
249-
import { useStore } from "@tanstack/react-store";
250-
import { Store, Derived } from "@tanstack/store";
251-
import "./App.css";
246+
import { useStore } from '@tanstack/react-store'
247+
import { Store, Derived } from '@tanstack/store'
248+
import './App.css'
252249

253-
const countStore = new Store(0);
250+
const countStore = new Store(0)
254251

255252
const doubledStore = new Derived({
256253
fn: () => countStore.state * 2,
257254
deps: [countStore],
258-
});
259-
doubledStore.mount();
255+
})
256+
doubledStore.mount()
260257

261258
function App() {
262-
const count = useStore(countStore);
263-
const doubledCount = useStore(doubledStore);
259+
const count = useStore(countStore)
260+
const doubledCount = useStore(doubledStore)
264261

265262
return (
266263
<div>
@@ -269,10 +266,10 @@ function App() {
269266
</button>
270267
<div>Doubled - {doubledCount}</div>
271268
</div>
272-
);
269+
)
273270
}
274271

275-
export default App;
272+
export default App
276273
```
277274

278275
We use the `Derived` class to create a new store that is derived from another store. The `Derived` class has a `mount` method that will start the derived store updating.

examples/react/start/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
"vitest": "^3.0.5",
3737
"web-vitals": "^4.2.4"
3838
}
39-
}
39+
}

examples/react/start/src/styles.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
@import "tailwindcss";
1+
@import 'tailwindcss';
22

33
body {
44
@apply m-0;
5-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
6-
"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
7-
sans-serif;
5+
font-family:
6+
-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu',
7+
'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
88
-webkit-font-smoothing: antialiased;
99
-moz-osx-font-smoothing: grayscale;
1010
}
1111

1212
code {
13-
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
14-
monospace;
13+
font-family:
14+
source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
1515
}

examples/react/start/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"noUncheckedSideEffectImports": true,
2323
"baseUrl": ".",
2424
"paths": {
25-
"@/*": ["./src/*"],
25+
"@/*": ["./src/*"]
2626
}
2727
}
2828
}

0 commit comments

Comments
 (0)