Skip to content

Commit 33acbf6

Browse files
committed
chore: update examples
1 parent 64b4719 commit 33acbf6

File tree

7 files changed

+12
-28
lines changed

7 files changed

+12
-28
lines changed

examples/nuxt-simple/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"dependencies": {
1212
"@nuxtjs/composition-api": "^0.28.0",
1313
"nuxt": "^2.0.0",
14-
"vue-query": "^1.5.1"
14+
"vue-query": ">=1.0.0"
1515
},
1616
"devDependencies": {
1717
"babel-eslint": "^10.0.1",

examples/nuxt-simple/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default defineComponent({
2727
2828
const { refetch, data, suspense } = useQuery("todos", fetcher, {
2929
// If you do not want data to be refetched on the client, set a staleTime to high enough time
30-
staleTime: 1000,
30+
staleTime: 5000,
3131
});
3232
3333
onServerPrefetch(async () => {

examples/nuxt-simple/plugins/vue-query.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { VueQueryPlugin, QueryClient, hydrate } from "vue-query";
44
export default (context) => {
55
// Modify your Vue Query global settings here
66
const queryClient = new QueryClient({
7-
defaultOptions: { queries: { staleTime: 1000 } },
7+
defaultOptions: { queries: { staleTime: 5000 } },
88
});
99
const options = { queryClient };
1010

1111
Vue.use(VueQueryPlugin, options);
1212

1313
if (process.client) {
14-
if (context.nuxtState && context.nuxtState["vue-query"]) {
15-
hydrate(queryClient, context.nuxtState["vue-query"]);
14+
if (context.nuxtState && context.nuxtState["vueQueryState"]) {
15+
hydrate(queryClient, context.nuxtState["vueQueryState"]);
1616
}
1717
}
1818
};

examples/nuxt3-simple/app.vue

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,15 @@
22
<div>{{ data }}</div>
33
</template>
44

5-
<script lang="ts">
5+
<script setup lang="ts">
66
import { useQuery } from "vue-query";
7-
import { defineComponent, onServerPrefetch } from "vue";
87
9-
interface Post {
10-
userId: number;
11-
id: number;
12-
title: string;
13-
body: string;
14-
}
15-
16-
const fetcher = async (): Promise<Post[]> =>
8+
const fetcher = async () =>
179
await fetch("https://jsonplaceholder.typicode.com/posts").then((response) =>
1810
response.json()
1911
);
2012
21-
export default defineComponent({
22-
setup() {
23-
const { data, suspense } = useQuery("test", fetcher);
24-
25-
onServerPrefetch(async () => {
26-
await suspense();
27-
});
13+
const { data, suspense } = useQuery("test", fetcher);
2814
29-
return { data };
30-
},
31-
});
15+
await suspense();
3216
</script>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineNuxtConfig } from "nuxt3";
1+
import { defineNuxtConfig } from "nuxt";
22

33
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config
44
export default defineNuxtConfig({});

examples/nuxt3-simple/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "node .output/server/index.mjs"
77
},
88
"devDependencies": {
9-
"nuxt3": "latest"
9+
"nuxt": "npm:nuxt3@latest"
1010
},
1111
"dependencies": {
1212
"vue-query": ">=1.0.0"

examples/nuxt3-simple/plugins/vue-query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
export default (nuxt) => {
1010
// Modify your Vue Query global settings here
1111
const queryClient = new QueryClient({
12-
defaultOptions: { queries: { staleTime: 1000 } },
12+
defaultOptions: { queries: { staleTime: 5000 } },
1313
});
1414
const options: VueQueryPluginOptions = { queryClient };
1515

0 commit comments

Comments
 (0)