From 293ea098666f2fbc7afcdf4ca5c044ef613022f9 Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Sun, 13 Oct 2024 22:26:42 +0200 Subject: [PATCH] docs: warn about `refreshNuxtData` not working with `asyncData` --- docs/3.api/3.utils/define-nuxt-component.md | 4 ++++ docs/3.api/3.utils/refresh-nuxt-data.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/docs/3.api/3.utils/define-nuxt-component.md b/docs/3.api/3.utils/define-nuxt-component.md index 7ee1073121..a7b11e07a7 100644 --- a/docs/3.api/3.utils/define-nuxt-component.md +++ b/docs/3.api/3.utils/define-nuxt-component.md @@ -36,6 +36,10 @@ export default defineNuxtComponent({ ``` +::warning +Data from `useAsyncData` is only set once in the `setup` hook of your component. This means `refreshNuxtData` will not work with `asyncData`. If you need to re-run `useAsyncData`, you can change it with a `method` of the Option API. +:: + ## `head()` If you choose not to use `setup()` in your app, you can use the `head()` method within your component definition: diff --git a/docs/3.api/3.utils/refresh-nuxt-data.md b/docs/3.api/3.utils/refresh-nuxt-data.md index 89770397b4..5c38f8858f 100644 --- a/docs/3.api/3.utils/refresh-nuxt-data.md +++ b/docs/3.api/3.utils/refresh-nuxt-data.md @@ -12,6 +12,10 @@ links: `refreshNuxtData` re-fetches all data from the server and updates the page as well as invalidates the cache of [`useAsyncData`](/docs/api/composables/use-async-data) , `useLazyAsyncData`, [`useFetch`](/docs/api/composables/use-fetch) and `useLazyFetch`. :: +::warning +`refreshNuxtData` only works with composition API. `asyncData` hook from the Options API does not work with `refreshNuxtData`. +:: + ## Type ```ts