Skip to content

Commit 89be189

Browse files
chore: update svelte examples and tests from runes PR
1 parent db60bdd commit 89be189

File tree

21 files changed

+35
-55
lines changed

21 files changed

+35
-55
lines changed

docs/framework/react/devtools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function App() {
7474

7575
### Options
7676

77-
- `initialIsOpen: Boolean`
77+
- `initialIsOpen: boolean`
7878
- Set this `true` if you want the dev tools to default to being open
7979
- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "relative"`
8080
- Defaults to `bottom-right`

docs/framework/solid/devtools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function App() {
6868

6969
### Options
7070

71-
- `initialIsOpen: Boolean`
71+
- `initialIsOpen: boolean`
7272
- Set this `true` if you want the dev tools to default to being open
7373
- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right"`
7474
- Defaults to `bottom-right`

docs/framework/svelte/devtools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Place the following code as high in your Svelte app as you can. The closer it is
6161

6262
### Options
6363

64-
- `initialIsOpen: Boolean`
64+
- `initialIsOpen: boolean`
6565
- Set this `true` if you want the dev tools to default to being open
6666
- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right" | "relative"`
6767
- Defaults to `bottom-right`

docs/framework/svelte/reactivity.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ In the below example, the `refetchInterval` option is set from the variable `int
1111
<script lang="ts">
1212
import { createQuery } from '@tanstack/svelte-query'
1313
14-
const endpoint = 'http://localhost:5173/api/data'
15-
1614
let intervalMs = 1000
1715
1816
const query = createQuery({
1917
queryKey: ['refetch'],
20-
queryFn: async () => await fetch(endpoint).then((r) => r.json()),
18+
queryFn: async () => await fetch('/api/data').then((r) => r.json()),
2119
refetchInterval: intervalMs,
2220
})
2321
</script>
@@ -32,14 +30,12 @@ To solve this, we can convert `intervalMs` into a writable store. The query opti
3230
import { derived, writable } from 'svelte/store'
3331
import { createQuery } from '@tanstack/svelte-query'
3432
35-
const endpoint = 'http://localhost:5173/api/data'
36-
3733
const intervalMs = writable(1000)
3834
3935
const query = createQuery(
4036
derived(intervalMs, ($intervalMs) => ({
4137
queryKey: ['refetch'],
42-
queryFn: async () => await fetch(endpoint).then((r) => r.json()),
38+
queryFn: async () => await fetch('/api/data').then((r) => r.json()),
4339
refetchInterval: $intervalMs,
4440
})),
4541
)

docs/framework/vue/devtools.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ import { VueQueryDevtools } from '@tanstack/vue-query-devtools'
6161

6262
### Options
6363

64-
- `initialIsOpen: Boolean`
64+
- `initialIsOpen: boolean`
6565
- Set this `true` if you want the dev tools to default to being open.
6666
- `buttonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right"`
6767
- Defaults to `bottom-right`.

examples/svelte/auto-refetching/src/routes/+page.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
const client = useQueryClient()
1212
13-
const endpoint = 'http://localhost:5173/api/data'
13+
const endpoint = '/api/data'
1414
1515
$: todos = createQuery<{ items: string[] }>({
1616
queryKey: ['refetch'],
@@ -21,7 +21,9 @@
2121
2222
const addMutation = createMutation({
2323
mutationFn: (value: string) =>
24-
fetch(`${endpoint}?add=${value}`).then((r) => r.json()),
24+
fetch(`${endpoint}?add=${encodeURIComponent(value)}`).then((r) =>
25+
r.json(),
26+
),
2527
onSuccess: () => client.invalidateQueries({ queryKey: ['refetch'] }),
2628
})
2729
@@ -31,7 +33,7 @@
3133
})
3234
</script>
3335

34-
<h1>Auto Refetch with stale-time set to 1s</h1>
36+
<h1>Auto Refetch with stale-time set to {intervalMs}ms</h1>
3537

3638
<p>
3739
This example is best experienced on your own machine, where you can open

examples/svelte/auto-refetching/svelte.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
33

44
/** @type {import('@sveltejs/kit').Config} */
55
const config = {
6-
// Consult https://github.com/sveltejs/svelte-preprocess
7-
// for more information about preprocessors
86
preprocess: vitePreprocess(),
9-
107
kit: {
118
adapter: adapter(),
129
},

examples/svelte/basic/svelte.config.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
33

44
/** @type {import('@sveltejs/kit').Config} */
55
const config = {
6-
// Consult https://github.com/sveltejs/svelte-preprocess
7-
// for more information about preprocessors
86
preprocess: vitePreprocess(),
9-
107
kit: {
118
adapter: adapter(),
129
},

examples/svelte/optimistic-updates/src/routes/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
2121
const client = useQueryClient()
2222
23-
const endpoint = 'http://localhost:5173/api/data'
23+
const endpoint = '/api/data'
2424
2525
const fetchTodos = async (): Promise<Todos> =>
2626
await fetch(endpoint).then((r) => r.json())

examples/svelte/optimistic-updates/src/routes/api/data/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type Todo = {
66
text: string
77
}
88

9-
const items: Todo[] = []
9+
const items: Array<Todo> = []
1010

1111
/** @type {import('./$types').RequestHandler} */
1212
export const GET: RequestHandler = async (req) => {

0 commit comments

Comments
 (0)